From 8b61c22ee33f728ae31d37c535280c2ca0c6a364 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 22:48:04 +0000 Subject: [PATCH 01/52] chore(internal): allow passing args to `./scripts/test` --- scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build b/scripts/build index f40634826..16a2b00db 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Building classes" -./gradlew build testClasses -x test +./gradlew build testClasses "$@" -x test From 7df6475b8742a8d3755c77f2168bfafdc0bf660a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 02:25:18 +0000 Subject: [PATCH 02/52] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Alert.kt | 205 +++++++++++++++++- .../api/models/AlertListPageResponseTest.kt | 3 + .../com/withorb/api/models/AlertTest.kt | 3 + 4 files changed, 211 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index e572dc254..a6cf36af7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9f1a41612765cb08d100b2c9e85080e93306e8d0942d535f16052c3eb18d9b8b.yml -openapi_spec_hash: 6dd28f36adc7e7d6a9245585eaf9b9c1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-931771ff4ab183044ee50ce43ea794ac0a15bfafbaf7df61ac0344af3ff08944.yml +openapi_spec_hash: 71371804e373f662585284bf5d93cc62 config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt index 5f3c0a922..971031581 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -39,6 +39,7 @@ private constructor( private val thresholds: JsonField>, private val type: JsonField, private val balanceAlertStatus: JsonField>, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -65,6 +66,9 @@ private constructor( @JsonProperty("balance_alert_status") @ExcludeMissing balanceAlertStatus: JsonField> = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, createdAt, @@ -77,6 +81,7 @@ private constructor( thresholds, type, balanceAlertStatus, + licenseType, mutableMapOf(), ) @@ -169,6 +174,14 @@ private constructor( fun balanceAlertStatus(): List? = balanceAlertStatus.getNullable("balance_alert_status") + /** + * Minified license type for alert serialization. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -257,6 +270,15 @@ private constructor( @ExcludeMissing fun _balanceAlertStatus(): JsonField> = balanceAlertStatus + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -305,6 +327,7 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null private var balanceAlertStatus: JsonField>? = null + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(alert: Alert) = apply { @@ -319,6 +342,7 @@ private constructor( thresholds = alert.thresholds.map { it.toMutableList() } type = alert.type balanceAlertStatus = alert.balanceAlertStatus.map { it.toMutableList() } + licenseType = alert.licenseType additionalProperties = alert.additionalProperties.toMutableMap() } @@ -482,6 +506,20 @@ private constructor( } } + /** Minified license type for alert serialization. */ + fun licenseType(licenseType: LicenseType?) = licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -535,6 +573,7 @@ private constructor( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), (balanceAlertStatus ?: JsonMissing.of()).map { it.toImmutable() }, + licenseType, additionalProperties.toMutableMap(), ) } @@ -557,6 +596,7 @@ private constructor( thresholds()?.forEach { it.validate() } type().validate() balanceAlertStatus()?.forEach { it.validate() } + licenseType()?.validate() validated = true } @@ -584,7 +624,8 @@ private constructor( (subscription.asKnown()?.validity() ?: 0) + (thresholds.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown()?.validity() ?: 0) + - (balanceAlertStatus.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (balanceAlertStatus.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) /** The metric the alert applies to. */ class Metric @@ -1047,6 +1088,8 @@ private constructor( val COST_EXCEEDED = of("cost_exceeded") + val LICENSE_BALANCE_THRESHOLD_REACHED = of("license_balance_threshold_reached") + fun of(value: String) = Type(JsonField.of(value)) } @@ -1057,6 +1100,7 @@ private constructor( CREDIT_BALANCE_RECOVERED, USAGE_EXCEEDED, COST_EXCEEDED, + LICENSE_BALANCE_THRESHOLD_REACHED, } /** @@ -1074,6 +1118,7 @@ private constructor( CREDIT_BALANCE_RECOVERED, USAGE_EXCEEDED, COST_EXCEEDED, + LICENSE_BALANCE_THRESHOLD_REACHED, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1092,6 +1137,7 @@ private constructor( CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED USAGE_EXCEEDED -> Value.USAGE_EXCEEDED COST_EXCEEDED -> Value.COST_EXCEEDED + LICENSE_BALANCE_THRESHOLD_REACHED -> Value.LICENSE_BALANCE_THRESHOLD_REACHED else -> Value._UNKNOWN } @@ -1110,6 +1156,7 @@ private constructor( CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED USAGE_EXCEEDED -> Known.USAGE_EXCEEDED COST_EXCEEDED -> Known.COST_EXCEEDED + LICENSE_BALANCE_THRESHOLD_REACHED -> Known.LICENSE_BALANCE_THRESHOLD_REACHED else -> throw OrbInvalidDataException("Unknown Type: $value") } @@ -1374,6 +1421,158 @@ private constructor( "BalanceAlertStatus{inAlert=$inAlert, thresholdValue=$thresholdValue, additionalProperties=$additionalProperties}" } + /** Minified license type for alert serialization. */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (id.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LicenseType{id=$id, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1391,6 +1590,7 @@ private constructor( thresholds == other.thresholds && type == other.type && balanceAlertStatus == other.balanceAlertStatus && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -1407,6 +1607,7 @@ private constructor( thresholds, type, balanceAlertStatus, + licenseType, additionalProperties, ) } @@ -1414,5 +1615,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, additionalProperties=$additionalProperties}" + "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, licenseType=$licenseType, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt index 8221015e9..39344d63e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt @@ -44,6 +44,7 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) .paginationMetadata( @@ -79,6 +80,7 @@ internal class AlertListPageResponseTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) assertThat(alertListPageResponse.paginationMetadata()) @@ -120,6 +122,7 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) .paginationMetadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt index 1ae716a80..c38fa163b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt @@ -39,6 +39,7 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() assertThat(alert.id()).isEqualTo("XuxCbt7x9L82yyeF") @@ -70,6 +71,7 @@ internal class AlertTest { .containsExactly( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + assertThat(alert.licenseType()).isEqualTo(Alert.LicenseType.builder().id("id").build()) } @Test @@ -102,6 +104,7 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() val roundtrippedAlert = From 8ea373173f2b39a788ecd61aa1f4e83b9a27b8e4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 20:56:15 +0000 Subject: [PATCH 03/52] chore(internal): upgrade AssertJ --- orb-kotlin-client-okhttp/build.gradle.kts | 2 +- orb-kotlin-core/build.gradle.kts | 2 +- orb-kotlin-proguard-test/build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/orb-kotlin-client-okhttp/build.gradle.kts b/orb-kotlin-client-okhttp/build.gradle.kts index a20491dc6..4085749ad 100644 --- a/orb-kotlin-client-okhttp/build.gradle.kts +++ b/orb-kotlin-client-okhttp/build.gradle.kts @@ -11,5 +11,5 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0") testImplementation(kotlin("test")) - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") } diff --git a/orb-kotlin-core/build.gradle.kts b/orb-kotlin-core/build.gradle.kts index 8e0f7a9b3..b86bb803d 100644 --- a/orb-kotlin-core/build.gradle.kts +++ b/orb-kotlin-core/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { testImplementation(kotlin("test")) testImplementation(project(":orb-kotlin-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") diff --git a/orb-kotlin-proguard-test/build.gradle.kts b/orb-kotlin-proguard-test/build.gradle.kts index a12866639..f63810fe2 100644 --- a/orb-kotlin-proguard-test/build.gradle.kts +++ b/orb-kotlin-proguard-test/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { testImplementation(project(":orb-kotlin")) testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } From a4e55fcd736a0e61da05512f1015c542b77b2e01 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 00:25:33 +0000 Subject: [PATCH 04/52] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/Allocation.kt | 58 +- .../api/models/BetaCreatePlanVersionParams.kt | 564 +- ...taExternalPlanIdCreatePlanVersionParams.kt | 564 +- ...editLedgerCreateEntryByExternalIdParams.kt | 3 +- .../CustomerCreditLedgerCreateEntryParams.kt | 3 +- .../withorb/api/models/NewAllocationPrice.kt | 46 +- .../api/models/NewFloatingBulkPrice.kt | 46 +- .../NewFloatingBulkWithProrationPrice.kt | 46 +- .../NewFloatingCumulativeGroupedBulkPrice.kt | 46 +- .../NewFloatingGroupedAllocationPrice.kt | 46 +- .../NewFloatingGroupedTieredPackagePrice.kt | 46 +- .../models/NewFloatingGroupedTieredPrice.kt | 46 +- ...wFloatingGroupedWithMeteredMinimumPrice.kt | 46 +- ...FloatingGroupedWithProratedMinimumPrice.kt | 46 +- .../api/models/NewFloatingMatrixPrice.kt | 46 +- .../NewFloatingMatrixWithAllocationPrice.kt | 46 +- .../NewFloatingMatrixWithDisplayNamePrice.kt | 46 +- .../NewFloatingMaxGroupTieredPackagePrice.kt | 46 +- .../NewFloatingMinimumCompositePrice.kt | 46 +- .../api/models/NewFloatingPackagePrice.kt | 46 +- .../NewFloatingPackageWithAllocationPrice.kt | 46 +- ...ingScalableMatrixWithTieredPricingPrice.kt | 46 +- ...atingScalableMatrixWithUnitPricingPrice.kt | 46 +- .../NewFloatingThresholdTotalAmountPrice.kt | 46 +- .../models/NewFloatingTieredPackagePrice.kt | 46 +- ...ewFloatingTieredPackageWithMinimumPrice.kt | 46 +- .../api/models/NewFloatingTieredPrice.kt | 46 +- .../NewFloatingTieredWithMinimumPrice.kt | 46 +- .../NewFloatingTieredWithProrationPrice.kt | 46 +- .../api/models/NewFloatingUnitPrice.kt | 46 +- .../models/NewFloatingUnitWithPercentPrice.kt | 46 +- .../NewFloatingUnitWithProrationPrice.kt | 46 +- .../withorb/api/models/NewPlanBulkPrice.kt | 46 +- .../models/NewPlanBulkWithProrationPrice.kt | 46 +- .../NewPlanCumulativeGroupedBulkPrice.kt | 46 +- .../models/NewPlanGroupedAllocationPrice.kt | 46 +- .../NewPlanGroupedTieredPackagePrice.kt | 46 +- .../api/models/NewPlanGroupedTieredPrice.kt | 46 +- .../NewPlanGroupedWithMeteredMinimumPrice.kt | 46 +- .../NewPlanGroupedWithProratedMinimumPrice.kt | 46 +- .../withorb/api/models/NewPlanMatrixPrice.kt | 46 +- .../NewPlanMatrixWithAllocationPrice.kt | 46 +- .../NewPlanMatrixWithDisplayNamePrice.kt | 46 +- .../NewPlanMaxGroupTieredPackagePrice.kt | 46 +- .../models/NewPlanMinimumCompositePrice.kt | 46 +- .../withorb/api/models/NewPlanPackagePrice.kt | 46 +- .../NewPlanPackageWithAllocationPrice.kt | 46 +- ...lanScalableMatrixWithTieredPricingPrice.kt | 46 +- ...wPlanScalableMatrixWithUnitPricingPrice.kt | 46 +- .../NewPlanThresholdTotalAmountPrice.kt | 46 +- .../api/models/NewPlanTieredPackagePrice.kt | 46 +- .../NewPlanTieredPackageWithMinimumPrice.kt | 46 +- .../withorb/api/models/NewPlanTieredPrice.kt | 46 +- .../models/NewPlanTieredWithMinimumPrice.kt | 46 +- .../withorb/api/models/NewPlanUnitPrice.kt | 46 +- .../api/models/NewPlanUnitWithPercentPrice.kt | 46 +- .../models/NewPlanUnitWithProrationPrice.kt | 46 +- .../api/models/NewSubscriptionBulkPrice.kt | 46 +- .../NewSubscriptionBulkWithProrationPrice.kt | 46 +- ...wSubscriptionCumulativeGroupedBulkPrice.kt | 46 +- .../NewSubscriptionGroupedAllocationPrice.kt | 46 +- ...ewSubscriptionGroupedTieredPackagePrice.kt | 46 +- .../NewSubscriptionGroupedTieredPrice.kt | 46 +- ...scriptionGroupedWithMeteredMinimumPrice.kt | 46 +- ...criptionGroupedWithProratedMinimumPrice.kt | 46 +- .../api/models/NewSubscriptionMatrixPrice.kt | 46 +- ...ewSubscriptionMatrixWithAllocationPrice.kt | 46 +- ...wSubscriptionMatrixWithDisplayNamePrice.kt | 46 +- ...wSubscriptionMaxGroupTieredPackagePrice.kt | 46 +- .../NewSubscriptionMinimumCompositePrice.kt | 46 +- .../api/models/NewSubscriptionPackagePrice.kt | 46 +- ...wSubscriptionPackageWithAllocationPrice.kt | 46 +- ...ionScalableMatrixWithTieredPricingPrice.kt | 46 +- ...ptionScalableMatrixWithUnitPricingPrice.kt | 46 +- ...ewSubscriptionThresholdTotalAmountPrice.kt | 46 +- .../NewSubscriptionTieredPackagePrice.kt | 46 +- ...bscriptionTieredPackageWithMinimumPrice.kt | 46 +- .../api/models/NewSubscriptionTieredPrice.kt | 46 +- .../NewSubscriptionTieredWithMinimumPrice.kt | 46 +- .../api/models/NewSubscriptionUnitPrice.kt | 46 +- .../NewSubscriptionUnitWithPercentPrice.kt | 46 +- .../NewSubscriptionUnitWithProrationPrice.kt | 46 +- .../withorb/api/models/PlanCreateParams.kt | 282 +- .../kotlin/com/withorb/api/models/Price.kt | 10157 +++++++++++++++- .../withorb/api/models/PriceCreateParams.kt | 235 +- .../api/models/PriceEvaluateMultipleParams.kt | 235 +- .../PriceEvaluatePreviewEventsParams.kt | 235 +- .../api/models/SubscriptionCreateParams.kt | 564 +- .../SubscriptionPriceIntervalsParams.kt | 235 +- .../SubscriptionSchedulePlanChangeParams.kt | 564 +- .../customers/credits/LedgerServiceAsync.kt | 6 +- .../customers/credits/LedgerService.kt | 6 +- .../withorb/api/models/AggregatedCostTest.kt | 24 + .../com/withorb/api/models/AllocationTest.kt | 3 + .../models/BetaCreatePlanVersionParamsTest.kt | 12 + ...ternalPlanIdCreatePlanVersionParamsTest.kt | 12 + .../ChangedSubscriptionResourcesTest.kt | 48 + ...ustomerCostListByExternalIdResponseTest.kt | 24 + .../models/CustomerCostListResponseTest.kt | 24 + ...dgerCreateEntryByExternalIdResponseTest.kt | 16 + ...omerCreditLedgerCreateEntryResponseTest.kt | 16 + ...tLedgerListByExternalIdPageResponseTest.kt | 24 + ...reditLedgerListByExternalIdResponseTest.kt | 16 + ...ustomerCreditLedgerListPageResponseTest.kt | 24 + .../CustomerCreditLedgerListResponseTest.kt | 16 + .../api/models/IncrementLedgerEntryTest.kt | 24 + .../InvoiceFetchUpcomingResponseTest.kt | 24 + .../InvoiceLineItemCreateResponseTest.kt | 24 + .../api/models/InvoiceListPageResponseTest.kt | 24 + .../com/withorb/api/models/InvoiceTest.kt | 24 + .../api/models/MutatedSubscriptionTest.kt | 96 + .../api/models/NewAllocationPriceTest.kt | 3 + .../api/models/NewFloatingBulkPriceTest.kt | 3 + .../NewFloatingBulkWithProrationPriceTest.kt | 3 + ...wFloatingCumulativeGroupedBulkPriceTest.kt | 4 + .../NewFloatingGroupedAllocationPriceTest.kt | 3 + ...ewFloatingGroupedTieredPackagePriceTest.kt | 4 + .../NewFloatingGroupedTieredPriceTest.kt | 3 + ...atingGroupedWithMeteredMinimumPriceTest.kt | 4 + ...tingGroupedWithProratedMinimumPriceTest.kt | 4 + .../api/models/NewFloatingMatrixPriceTest.kt | 3 + ...ewFloatingMatrixWithAllocationPriceTest.kt | 4 + ...wFloatingMatrixWithDisplayNamePriceTest.kt | 4 + ...wFloatingMaxGroupTieredPackagePriceTest.kt | 4 + .../NewFloatingMinimumCompositePriceTest.kt | 3 + .../api/models/NewFloatingPackagePriceTest.kt | 3 + ...wFloatingPackageWithAllocationPriceTest.kt | 4 + ...calableMatrixWithTieredPricingPriceTest.kt | 4 + ...gScalableMatrixWithUnitPricingPriceTest.kt | 4 + ...ewFloatingThresholdTotalAmountPriceTest.kt | 4 + .../NewFloatingTieredPackagePriceTest.kt | 3 + ...oatingTieredPackageWithMinimumPriceTest.kt | 4 + .../api/models/NewFloatingTieredPriceTest.kt | 3 + .../NewFloatingTieredWithMinimumPriceTest.kt | 3 + ...NewFloatingTieredWithProrationPriceTest.kt | 3 + .../api/models/NewFloatingUnitPriceTest.kt | 3 + .../NewFloatingUnitWithPercentPriceTest.kt | 3 + .../NewFloatingUnitWithProrationPriceTest.kt | 3 + .../api/models/NewPlanBulkPriceTest.kt | 3 + .../NewPlanBulkWithProrationPriceTest.kt | 3 + .../NewPlanCumulativeGroupedBulkPriceTest.kt | 3 + .../NewPlanGroupedAllocationPriceTest.kt | 3 + .../NewPlanGroupedTieredPackagePriceTest.kt | 3 + .../models/NewPlanGroupedTieredPriceTest.kt | 3 + ...wPlanGroupedWithMeteredMinimumPriceTest.kt | 4 + ...PlanGroupedWithProratedMinimumPriceTest.kt | 4 + .../api/models/NewPlanMatrixPriceTest.kt | 3 + .../NewPlanMatrixWithAllocationPriceTest.kt | 3 + .../NewPlanMatrixWithDisplayNamePriceTest.kt | 3 + .../NewPlanMaxGroupTieredPackagePriceTest.kt | 3 + .../NewPlanMinimumCompositePriceTest.kt | 3 + .../api/models/NewPlanPackagePriceTest.kt | 3 + .../NewPlanPackageWithAllocationPriceTest.kt | 3 + ...calableMatrixWithTieredPricingPriceTest.kt | 4 + ...nScalableMatrixWithUnitPricingPriceTest.kt | 4 + .../NewPlanThresholdTotalAmountPriceTest.kt | 3 + .../models/NewPlanTieredPackagePriceTest.kt | 3 + ...ewPlanTieredPackageWithMinimumPriceTest.kt | 4 + .../api/models/NewPlanTieredPriceTest.kt | 3 + .../NewPlanTieredWithMinimumPriceTest.kt | 3 + .../api/models/NewPlanUnitPriceTest.kt | 3 + .../models/NewPlanUnitWithPercentPriceTest.kt | 3 + .../NewPlanUnitWithProrationPriceTest.kt | 3 + .../models/NewSubscriptionBulkPriceTest.kt | 3 + ...wSubscriptionBulkWithProrationPriceTest.kt | 4 + ...scriptionCumulativeGroupedBulkPriceTest.kt | 4 + ...wSubscriptionGroupedAllocationPriceTest.kt | 4 + ...bscriptionGroupedTieredPackagePriceTest.kt | 4 + .../NewSubscriptionGroupedTieredPriceTest.kt | 3 + ...ptionGroupedWithMeteredMinimumPriceTest.kt | 4 + ...tionGroupedWithProratedMinimumPriceTest.kt | 4 + .../models/NewSubscriptionMatrixPriceTest.kt | 3 + ...bscriptionMatrixWithAllocationPriceTest.kt | 4 + ...scriptionMatrixWithDisplayNamePriceTest.kt | 4 + ...scriptionMaxGroupTieredPackagePriceTest.kt | 4 + ...ewSubscriptionMinimumCompositePriceTest.kt | 4 + .../models/NewSubscriptionPackagePriceTest.kt | 3 + ...scriptionPackageWithAllocationPriceTest.kt | 4 + ...calableMatrixWithTieredPricingPriceTest.kt | 4 + ...nScalableMatrixWithUnitPricingPriceTest.kt | 4 + ...bscriptionThresholdTotalAmountPriceTest.kt | 4 + .../NewSubscriptionTieredPackagePriceTest.kt | 3 + ...iptionTieredPackageWithMinimumPriceTest.kt | 4 + .../models/NewSubscriptionTieredPriceTest.kt | 3 + ...wSubscriptionTieredWithMinimumPriceTest.kt | 4 + .../models/NewSubscriptionUnitPriceTest.kt | 3 + ...NewSubscriptionUnitWithPercentPriceTest.kt | 3 + ...wSubscriptionUnitWithProrationPriceTest.kt | 4 + .../withorb/api/models/PerPriceCostTest.kt | 24 + .../api/models/PlanCreateParamsTest.kt | 6 + .../api/models/PlanListPageResponseTest.kt | 24 + .../kotlin/com/withorb/api/models/PlanTest.kt | 24 + .../com/withorb/api/models/PlanVersionTest.kt | 24 + .../api/models/PriceCreateParamsTest.kt | 3 + .../models/PriceEvaluateMultipleParamsTest.kt | 3 + .../PriceEvaluatePreviewEventsParamsTest.kt | 3 + .../withorb/api/models/PriceIntervalTest.kt | 24 + .../api/models/PriceListPageResponseTest.kt | 24 + .../com/withorb/api/models/PriceTest.kt | 496 + .../SubscriptionChangeApplyResponseTest.kt | 96 + .../SubscriptionChangeCancelResponseTest.kt | 96 + .../SubscriptionChangeRetrieveResponseTest.kt | 96 + .../models/SubscriptionCreateParamsTest.kt | 12 + .../SubscriptionFetchCostsResponseTest.kt | 24 + .../SubscriptionPriceIntervalsParamsTest.kt | 6 + ...ubscriptionSchedulePlanChangeParamsTest.kt | 12 + .../withorb/api/models/SubscriptionTest.kt | 48 + .../withorb/api/models/SubscriptionsTest.kt | 48 + .../services/async/BetaServiceAsyncTest.kt | 4 + .../services/async/PlanServiceAsyncTest.kt | 2 + .../services/async/PriceServiceAsyncTest.kt | 3 + .../async/SubscriptionServiceAsyncTest.kt | 10 + .../beta/ExternalPlanIdServiceAsyncTest.kt | 4 + .../api/services/blocking/BetaServiceTest.kt | 4 + .../api/services/blocking/PlanServiceTest.kt | 2 + .../api/services/blocking/PriceServiceTest.kt | 3 + .../blocking/SubscriptionServiceTest.kt | 10 + .../beta/ExternalPlanIdServiceTest.kt | 4 + 219 files changed, 18621 insertions(+), 515 deletions(-) diff --git a/.stats.yml b/.stats.yml index a6cf36af7..a77b80771 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-931771ff4ab183044ee50ce43ea794ac0a15bfafbaf7df61ac0344af3ff08944.yml -openapi_spec_hash: 71371804e373f662585284bf5d93cc62 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6aa83a816c15600a3d6d378d7804a345505c76726059c19369db4e7766a71cbd.yml +openapi_spec_hash: f283d730e5320f9595c3c0a5902f5cbb config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index ae54b8ec3..1b59838a5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -25,6 +25,7 @@ private constructor( private val currency: JsonField, private val customExpiration: JsonField, private val filters: JsonField>, + private val licenseTypeId: JsonField, private val additionalProperties: MutableMap, ) { @@ -37,8 +38,13 @@ private constructor( @JsonProperty("custom_expiration") @ExcludeMissing customExpiration: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField> = JsonMissing.of(), - ) : this(allowsRollover, currency, customExpiration, filters, mutableMapOf()) + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + ) : this(allowsRollover, currency, customExpiration, filters, licenseTypeId, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -64,6 +70,12 @@ private constructor( */ fun filters(): List? = filters.getNullable("filters") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_id") + /** * Returns the raw JSON value of [allowsRollover]. * @@ -97,6 +109,15 @@ private constructor( */ @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -131,6 +152,7 @@ private constructor( private var currency: JsonField? = null private var customExpiration: JsonField? = null private var filters: JsonField>? = null + private var licenseTypeId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(allocation: Allocation) = apply { @@ -138,6 +160,7 @@ private constructor( currency = allocation.currency customExpiration = allocation.customExpiration filters = allocation.filters.map { it.toMutableList() } + licenseTypeId = allocation.licenseTypeId additionalProperties = allocation.additionalProperties.toMutableMap() } @@ -203,6 +226,20 @@ private constructor( } } + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -242,6 +279,7 @@ private constructor( checkRequired("currency", currency), checkRequired("customExpiration", customExpiration), (filters ?: JsonMissing.of()).map { it.toImmutable() }, + licenseTypeId, additionalProperties.toMutableMap(), ) } @@ -257,6 +295,7 @@ private constructor( currency() customExpiration()?.validate() filters()?.forEach { it.validate() } + licenseTypeId() validated = true } @@ -277,7 +316,8 @@ private constructor( (if (allowsRollover.asKnown() == null) 0 else 1) + (if (currency.asKnown() == null) 0 else 1) + (customExpiration.asKnown()?.validity() ?: 0) + - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -817,15 +857,23 @@ private constructor( currency == other.currency && customExpiration == other.customExpiration && filters == other.filters && + licenseTypeId == other.licenseTypeId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allowsRollover, currency, customExpiration, filters, additionalProperties) + Objects.hash( + allowsRollover, + currency, + customExpiration, + filters, + licenseTypeId, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, additionalProperties=$additionalProperties}" + "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, licenseTypeId=$licenseTypeId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 3ee9a727a..49d240389 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -3323,6 +3323,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -3381,6 +3382,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3404,6 +3408,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -3559,6 +3564,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -3728,6 +3741,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3801,6 +3824,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3823,6 +3847,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -4165,6 +4190,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -4254,6 +4294,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -4287,6 +4328,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -4323,6 +4365,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -5303,6 +5346,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -5326,6 +5370,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -5335,7 +5380,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -5358,6 +5403,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5417,6 +5463,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5440,6 +5489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5595,6 +5645,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -5764,6 +5822,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5839,6 +5907,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5862,6 +5931,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -6206,6 +6276,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6295,6 +6380,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6328,6 +6414,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -6366,6 +6453,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -7072,6 +7160,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7095,6 +7184,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7104,7 +7194,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -7128,6 +7218,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7188,6 +7279,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7211,6 +7305,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -7368,6 +7463,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -7537,6 +7640,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7614,6 +7727,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7640,6 +7754,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -7991,6 +8106,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8083,6 +8213,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8116,6 +8247,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -8154,6 +8286,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -8770,6 +8903,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8793,6 +8927,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8802,7 +8937,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -8826,6 +8961,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8886,6 +9022,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8909,6 +9048,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -9066,6 +9206,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -9235,6 +9383,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9312,6 +9470,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9338,6 +9497,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -9689,6 +9849,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9781,6 +9956,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9814,6 +9990,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -9852,6 +10029,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -10475,6 +10653,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10498,6 +10677,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10507,7 +10687,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -10530,6 +10710,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10588,6 +10769,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10611,6 +10795,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10765,6 +10950,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10933,6 +11126,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11006,6 +11209,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11027,6 +11231,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -11369,6 +11574,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11458,6 +11678,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11491,6 +11712,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -11527,6 +11749,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -11990,6 +12213,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12013,6 +12237,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12022,7 +12247,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -12045,6 +12270,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12103,6 +12329,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12126,6 +12355,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12281,6 +12511,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -12449,6 +12687,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12522,6 +12770,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12543,6 +12792,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -12885,6 +13135,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12974,6 +13239,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13007,6 +13273,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -13043,6 +13310,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -13613,6 +13881,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13636,6 +13905,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13645,7 +13915,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -16422,6 +16692,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -16480,6 +16751,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -16503,6 +16777,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -16658,6 +16933,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -16827,6 +17110,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -16900,6 +17193,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -16922,6 +17216,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -17264,6 +17559,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -17353,6 +17663,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -17386,6 +17697,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -17422,6 +17734,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -18402,6 +18715,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -18425,6 +18739,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -18434,7 +18749,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -18457,6 +18772,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -18516,6 +18832,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -18539,6 +18858,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -18694,6 +19014,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -18863,6 +19191,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -18938,6 +19276,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -18961,6 +19300,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -19305,6 +19645,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -19394,6 +19749,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -19427,6 +19783,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -19465,6 +19822,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -20171,6 +20529,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -20194,6 +20553,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -20203,7 +20563,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -20227,6 +20587,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -20287,6 +20648,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -20310,6 +20674,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -20467,6 +20832,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -20636,6 +21009,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -20713,6 +21096,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -20739,6 +21123,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -21090,6 +21475,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -21182,6 +21582,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -21215,6 +21616,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -21253,6 +21655,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -21869,6 +22272,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21892,6 +22296,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21901,7 +22306,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -21925,6 +22330,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21985,6 +22391,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -22008,6 +22417,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -22165,6 +22575,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -22334,6 +22752,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -22411,6 +22839,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -22437,6 +22866,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -22788,6 +23218,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22880,6 +23325,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22913,6 +23359,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -22951,6 +23398,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -23574,6 +24022,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23597,6 +24046,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23606,7 +24056,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -23629,6 +24079,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23687,6 +24138,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23710,6 +24164,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23864,6 +24319,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -24032,6 +24495,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -24105,6 +24578,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -24126,6 +24600,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -24468,6 +24943,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24557,6 +25047,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24590,6 +25081,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -24626,6 +25118,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -25089,6 +25582,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -25112,6 +25606,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -25121,7 +25616,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -25144,6 +25639,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -25202,6 +25698,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -25225,6 +25724,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25380,6 +25880,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -25548,6 +26056,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25621,6 +26139,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25642,6 +26161,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -25984,6 +26504,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -26073,6 +26608,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -26106,6 +26642,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -26142,6 +26679,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -26712,6 +27250,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26735,6 +27274,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26744,7 +27284,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 2da7fc284..e6fcb3678 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -3328,6 +3328,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -3386,6 +3387,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3409,6 +3413,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -3564,6 +3569,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -3733,6 +3746,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3806,6 +3829,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3828,6 +3852,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -4170,6 +4195,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -4259,6 +4299,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -4292,6 +4333,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -4328,6 +4370,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -5308,6 +5351,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -5331,6 +5375,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -5340,7 +5385,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -5363,6 +5408,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5422,6 +5468,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5445,6 +5494,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5600,6 +5650,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -5769,6 +5827,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5844,6 +5912,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5867,6 +5936,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -6211,6 +6281,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6300,6 +6385,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6333,6 +6419,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -6371,6 +6458,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -7077,6 +7165,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7100,6 +7189,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7109,7 +7199,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -7133,6 +7223,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7193,6 +7284,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7216,6 +7310,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -7373,6 +7468,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -7542,6 +7645,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7619,6 +7732,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7645,6 +7759,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -7996,6 +8111,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8088,6 +8218,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8121,6 +8252,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -8159,6 +8291,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -8775,6 +8908,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8798,6 +8932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8807,7 +8942,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -8831,6 +8966,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8891,6 +9027,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8914,6 +9053,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -9071,6 +9211,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -9240,6 +9388,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9317,6 +9475,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9343,6 +9502,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -9694,6 +9854,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9786,6 +9961,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9819,6 +9995,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -9857,6 +10034,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -10480,6 +10658,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10503,6 +10682,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10512,7 +10692,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -10535,6 +10715,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10593,6 +10774,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10616,6 +10800,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10770,6 +10955,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10938,6 +11131,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11011,6 +11214,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11032,6 +11236,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -11374,6 +11579,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11463,6 +11683,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11496,6 +11717,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -11532,6 +11754,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -11995,6 +12218,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12018,6 +12242,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12027,7 +12252,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -12050,6 +12275,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12108,6 +12334,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12131,6 +12360,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12286,6 +12516,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -12454,6 +12692,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12527,6 +12775,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12548,6 +12797,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -12890,6 +13140,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12979,6 +13244,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13012,6 +13278,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -13048,6 +13315,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -13618,6 +13886,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13641,6 +13910,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13650,7 +13920,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -16427,6 +16697,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -16485,6 +16756,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -16508,6 +16782,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -16663,6 +16938,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -16832,6 +17115,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -16905,6 +17198,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -16927,6 +17221,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -17269,6 +17564,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -17358,6 +17668,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -17391,6 +17702,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -17427,6 +17739,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -18407,6 +18720,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -18430,6 +18744,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -18439,7 +18754,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -18462,6 +18777,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -18521,6 +18837,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -18544,6 +18863,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -18699,6 +19019,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -18868,6 +19196,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -18943,6 +19281,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -18966,6 +19305,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -19310,6 +19650,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -19399,6 +19754,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -19432,6 +19788,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -19470,6 +19827,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -20176,6 +20534,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -20199,6 +20558,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -20208,7 +20568,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -20232,6 +20592,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -20292,6 +20653,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -20315,6 +20679,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -20472,6 +20837,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -20641,6 +21014,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -20718,6 +21101,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -20744,6 +21128,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -21095,6 +21480,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -21187,6 +21587,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -21220,6 +21621,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -21258,6 +21660,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -21874,6 +22277,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21897,6 +22301,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21906,7 +22311,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -21930,6 +22335,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21990,6 +22396,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -22013,6 +22422,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -22170,6 +22580,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -22339,6 +22757,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -22416,6 +22844,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -22442,6 +22871,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -22793,6 +23223,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22885,6 +23330,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22918,6 +23364,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -22956,6 +23403,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -23579,6 +24027,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23602,6 +24051,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23611,7 +24061,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -23634,6 +24084,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23692,6 +24143,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23715,6 +24169,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23869,6 +24324,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -24037,6 +24500,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -24110,6 +24583,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -24131,6 +24605,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -24473,6 +24948,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24562,6 +25052,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24595,6 +25086,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -24631,6 +25123,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -25094,6 +25587,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -25117,6 +25611,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -25126,7 +25621,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -25149,6 +25644,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -25207,6 +25703,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -25230,6 +25729,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25385,6 +25885,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -25553,6 +26061,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25626,6 +26144,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25647,6 +26166,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -25989,6 +26509,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -26078,6 +26613,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -26111,6 +26647,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -26147,6 +26684,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -26717,6 +27255,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26740,6 +27279,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26749,7 +27289,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 0e73faaa0..25f96583e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -76,7 +76,8 @@ import java.util.Objects * 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. + * cost basis with the number of credit units added. Additionally, Orb also enforces invoice + * generation when a non-zero `per_unit_cost_basis` value is provided. * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 9e2878dde..2d6992629 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -76,7 +76,8 @@ import java.util.Objects * 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. + * cost basis with the number of credit units added. Additionally, Orb also enforces invoice + * generation when a non-zero `per_unit_cost_basis` value is provided. * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index 17669e69c..ce8018955 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -28,6 +28,7 @@ private constructor( private val expiresAtEndOfCadence: JsonField, private val filters: JsonField>, private val itemId: JsonField, + private val licenseTypeId: JsonField, private val perUnitCostBasis: JsonField, private val additionalProperties: MutableMap, ) { @@ -47,6 +48,9 @@ private constructor( @ExcludeMissing filters: JsonField> = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -58,6 +62,7 @@ private constructor( expiresAtEndOfCadence, filters, itemId, + licenseTypeId, perUnitCostBasis, mutableMapOf(), ) @@ -122,6 +127,14 @@ private constructor( */ fun itemId(): String? = itemId.getNullable("item_id") + /** + * The license type ID to associate the price with license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_id") + /** * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced * according to the quantity and per unit cost basis specified for the allocation each cadence. @@ -186,6 +199,15 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -233,6 +255,7 @@ private constructor( private var expiresAtEndOfCadence: JsonField = JsonMissing.of() private var filters: JsonField>? = null private var itemId: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var perUnitCostBasis: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -244,6 +267,7 @@ private constructor( expiresAtEndOfCadence = newAllocationPrice.expiresAtEndOfCadence filters = newAllocationPrice.filters.map { it.toMutableList() } itemId = newAllocationPrice.itemId + licenseTypeId = newAllocationPrice.licenseTypeId perUnitCostBasis = newAllocationPrice.perUnitCostBasis additionalProperties = newAllocationPrice.additionalProperties.toMutableMap() } @@ -366,6 +390,21 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The license type ID to associate the price with license allocation. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced * according to the quantity and per unit cost basis specified for the allocation each @@ -427,6 +466,7 @@ private constructor( expiresAtEndOfCadence, (filters ?: JsonMissing.of()).map { it.toImmutable() }, itemId, + licenseTypeId, perUnitCostBasis, additionalProperties.toMutableMap(), ) @@ -446,6 +486,7 @@ private constructor( expiresAtEndOfCadence() filters()?.forEach { it.validate() } itemId() + licenseTypeId() perUnitCostBasis() validated = true } @@ -471,6 +512,7 @@ private constructor( (if (expiresAtEndOfCadence.asKnown() == null) 0 else 1) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) /** The cadence at which to allocate the amount to the customer. */ @@ -1134,6 +1176,7 @@ private constructor( expiresAtEndOfCadence == other.expiresAtEndOfCadence && filters == other.filters && itemId == other.itemId && + licenseTypeId == other.licenseTypeId && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties } @@ -1147,6 +1190,7 @@ private constructor( expiresAtEndOfCadence, filters, itemId, + licenseTypeId, perUnitCostBasis, additionalProperties, ) @@ -1155,5 +1199,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, licenseTypeId=$licenseTypeId, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index 64a979ece..fff42bdf7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( bulkConfig, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -239,6 +244,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -393,6 +406,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -452,6 +474,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -472,6 +495,7 @@ private constructor( fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingBulkPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingBulkPrice.licenseTypeId metadata = newFloatingBulkPrice.metadata additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() } @@ -768,6 +792,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -838,6 +877,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -866,6 +906,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -900,6 +941,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1296,6 +1338,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1318,6 +1361,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1326,5 +1370,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 79143b0ba..3c55904af 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( bulkWithProrationConfig, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -396,6 +409,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -480,6 +503,7 @@ private constructor( invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingBulkWithProrationPrice.licenseTypeId metadata = newFloatingBulkWithProrationPrice.metadata additionalProperties = newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() @@ -781,6 +805,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -851,6 +890,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -879,6 +919,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -913,6 +954,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** Configuration for bulk_with_proration pricing */ @@ -1698,6 +1740,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1720,6 +1763,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1728,5 +1772,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index f66c264c9..ed135c07b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -457,6 +479,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -483,6 +506,7 @@ private constructor( invoiceGroupingKey = newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingCumulativeGroupedBulkPrice.licenseTypeId metadata = newFloatingCumulativeGroupedBulkPrice.metadata additionalProperties = newFloatingCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() @@ -783,6 +807,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -853,6 +892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -881,6 +921,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -915,6 +956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1795,6 +1837,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1817,6 +1860,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1825,5 +1869,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index 8462624bb..1346c9b9a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -240,6 +245,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -395,6 +408,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -455,6 +477,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -479,6 +502,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedAllocationPrice.licenseTypeId metadata = newFloatingGroupedAllocationPrice.metadata additionalProperties = newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() @@ -780,6 +804,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -850,6 +889,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -878,6 +918,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -912,6 +953,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1562,6 +1604,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1584,6 +1627,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1592,5 +1636,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index dc56904ba..14d5bf421 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -457,6 +479,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -483,6 +506,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedTieredPackagePrice.licenseTypeId metadata = newFloatingGroupedTieredPackagePrice.metadata additionalProperties = newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() @@ -783,6 +807,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -853,6 +892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -881,6 +921,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -915,6 +956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1787,6 +1829,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1809,6 +1852,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1817,5 +1861,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index aa38774b8..2e03535ac 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -396,6 +409,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedTieredPrice.licenseTypeId metadata = newFloatingGroupedTieredPrice.metadata additionalProperties = newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() } @@ -776,6 +800,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -846,6 +885,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -874,6 +914,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -908,6 +949,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1739,6 +1781,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1761,6 +1804,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1769,5 +1813,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index f044abc55..b220fe849 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -242,6 +247,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -398,6 +411,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -485,6 +508,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata additionalProperties = newFloatingGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() @@ -786,6 +810,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -856,6 +895,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -884,6 +924,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -918,6 +959,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -2176,6 +2218,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2198,6 +2241,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2206,5 +2250,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index 2b2c17136..4dcf5927d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -458,6 +480,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedWithProratedMinimumPrice.licenseTypeId metadata = newFloatingGroupedWithProratedMinimumPrice.metadata additionalProperties = newFloatingGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() @@ -785,6 +809,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -855,6 +894,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -883,6 +923,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -917,6 +958,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1560,6 +1602,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1582,6 +1625,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1590,5 +1634,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index 22a6cb68e..c00428cf9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -239,6 +244,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -393,6 +406,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -452,6 +474,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -472,6 +495,7 @@ private constructor( fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixPrice.licenseTypeId metadata = newFloatingMatrixPrice.metadata additionalProperties = newFloatingMatrixPrice.additionalProperties.toMutableMap() } @@ -770,6 +794,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -840,6 +879,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -868,6 +908,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -902,6 +943,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1298,6 +1340,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1320,6 +1363,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1328,5 +1372,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 3dc9bdce0..164ad94fd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -240,6 +245,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -396,6 +409,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -482,6 +505,7 @@ private constructor( invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixWithAllocationPrice.licenseTypeId metadata = newFloatingMatrixWithAllocationPrice.metadata additionalProperties = newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() @@ -782,6 +806,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -852,6 +891,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -880,6 +920,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -914,6 +955,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1310,6 +1352,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1332,6 +1375,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1340,5 +1384,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 4f282c571..e45c1f44a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -457,6 +479,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -483,6 +506,7 @@ private constructor( invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixWithDisplayNamePrice.licenseTypeId metadata = newFloatingMatrixWithDisplayNamePrice.metadata additionalProperties = newFloatingMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() @@ -783,6 +807,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -853,6 +892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -881,6 +921,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -915,6 +956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1796,6 +1838,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1818,6 +1861,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1826,5 +1870,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index 85015bc73..e0cb98866 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -457,6 +479,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -483,6 +506,7 @@ private constructor( invoiceGroupingKey = newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMaxGroupTieredPackagePrice.licenseTypeId metadata = newFloatingMaxGroupTieredPackagePrice.metadata additionalProperties = newFloatingMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() @@ -783,6 +807,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -853,6 +892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -881,6 +921,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -915,6 +956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1788,6 +1830,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1810,6 +1853,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1818,5 +1862,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt index 1a1d49ba8..18fb64848 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -240,6 +245,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -395,6 +408,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -455,6 +477,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -479,6 +502,7 @@ private constructor( invoiceGroupingKey = newFloatingMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMinimumCompositePrice.licenseTypeId metadata = newFloatingMinimumCompositePrice.metadata additionalProperties = newFloatingMinimumCompositePrice.additionalProperties.toMutableMap() @@ -780,6 +804,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -850,6 +889,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -878,6 +918,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -912,6 +953,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1514,6 +1556,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1536,6 +1579,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1544,5 +1588,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index deae399c2..9494ff0ab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -239,6 +244,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -393,6 +406,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -452,6 +474,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -472,6 +495,7 @@ private constructor( fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingPackagePrice.licenseTypeId metadata = newFloatingPackagePrice.metadata additionalProperties = newFloatingPackagePrice.additionalProperties.toMutableMap() } @@ -770,6 +794,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -840,6 +879,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -868,6 +908,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -902,6 +943,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1298,6 +1340,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1320,6 +1363,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1328,5 +1372,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index 0fe8955b5..f4ecbfa28 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -240,6 +245,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -396,6 +409,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -482,6 +505,7 @@ private constructor( invoiceGroupingKey = newFloatingPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingPackageWithAllocationPrice.licenseTypeId metadata = newFloatingPackageWithAllocationPrice.metadata additionalProperties = newFloatingPackageWithAllocationPrice.additionalProperties.toMutableMap() @@ -782,6 +806,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -852,6 +891,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -880,6 +920,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -914,6 +955,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1556,6 +1598,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1578,6 +1621,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1586,5 +1630,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 3ee93ec8e..983de4575 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -463,6 +485,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -492,6 +515,7 @@ private constructor( invoiceGroupingKey = newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata additionalProperties = newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() @@ -798,6 +822,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -871,6 +910,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -899,6 +939,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -933,6 +974,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -2138,6 +2180,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2160,6 +2203,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2168,5 +2212,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 136fe4404..03f76e139 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -242,6 +247,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -398,6 +411,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata additionalProperties = newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() @@ -789,6 +813,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -862,6 +901,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -890,6 +930,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -924,6 +965,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1957,6 +1999,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1979,6 +2022,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1987,5 +2031,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index b04b6c0ca..e4311998a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -457,6 +479,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -483,6 +506,7 @@ private constructor( invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingThresholdTotalAmountPrice.licenseTypeId metadata = newFloatingThresholdTotalAmountPrice.metadata additionalProperties = newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() @@ -783,6 +807,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -853,6 +892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -881,6 +921,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -915,6 +956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1756,6 +1798,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1778,6 +1821,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1786,5 +1830,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index b47f85711..8381f62e7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -396,6 +409,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPackagePrice.licenseTypeId metadata = newFloatingTieredPackagePrice.metadata additionalProperties = newFloatingTieredPackagePrice.additionalProperties.toMutableMap() } @@ -776,6 +800,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -846,6 +885,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -874,6 +914,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -908,6 +949,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1737,6 +1779,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1759,6 +1802,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1767,5 +1811,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index 701a9a897..538983bdd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -242,6 +247,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -398,6 +411,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -485,6 +508,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPackageWithMinimumPrice.licenseTypeId metadata = newFloatingTieredPackageWithMinimumPrice.metadata additionalProperties = newFloatingTieredPackageWithMinimumPrice.additionalProperties.toMutableMap() @@ -786,6 +810,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -856,6 +895,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -884,6 +924,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -918,6 +959,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1786,6 +1828,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1808,6 +1851,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1816,5 +1860,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index 88f9c93dc..dea32978f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -239,6 +244,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -393,6 +406,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -452,6 +474,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -472,6 +495,7 @@ private constructor( fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPrice.licenseTypeId metadata = newFloatingTieredPrice.metadata additionalProperties = newFloatingTieredPrice.additionalProperties.toMutableMap() } @@ -770,6 +794,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -840,6 +879,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -868,6 +908,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -902,6 +943,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1298,6 +1340,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1320,6 +1363,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1328,5 +1372,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index 5a9f1a900..ec4c5f748 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -396,6 +409,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -480,6 +503,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredWithMinimumPrice.licenseTypeId metadata = newFloatingTieredWithMinimumPrice.metadata additionalProperties = newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() @@ -781,6 +805,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -851,6 +890,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -879,6 +919,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -913,6 +954,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1827,6 +1869,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1849,6 +1892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1857,5 +1901,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index 20ff69406..414f72ac4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -102,6 +106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -241,6 +246,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -457,6 +479,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -483,6 +506,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredWithProrationPrice.licenseTypeId metadata = newFloatingTieredWithProrationPrice.metadata additionalProperties = newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() @@ -783,6 +807,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -853,6 +892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -881,6 +921,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -915,6 +956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1707,6 +1749,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1729,6 +1772,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1737,5 +1781,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index d3bed4168..55b8ddc8d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -239,6 +244,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -393,6 +406,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -452,6 +474,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -472,6 +495,7 @@ private constructor( fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitPrice.licenseTypeId metadata = newFloatingUnitPrice.metadata additionalProperties = newFloatingUnitPrice.additionalProperties.toMutableMap() } @@ -768,6 +792,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -838,6 +877,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -866,6 +906,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -900,6 +941,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1296,6 +1338,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1318,6 +1361,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1326,5 +1370,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index d557569fb..adaf0a3c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -240,6 +245,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -395,6 +408,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -455,6 +477,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -479,6 +502,7 @@ private constructor( invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitWithPercentPrice.licenseTypeId metadata = newFloatingUnitWithPercentPrice.metadata additionalProperties = newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() @@ -779,6 +803,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -849,6 +888,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -877,6 +917,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -911,6 +952,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1509,6 +1551,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1531,6 +1574,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1539,5 +1583,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index 055f55045..9198a15ef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -83,6 +84,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -101,6 +105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -240,6 +245,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -395,6 +408,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -455,6 +477,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -479,6 +502,7 @@ private constructor( invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitWithProrationPrice.licenseTypeId metadata = newFloatingUnitWithProrationPrice.metadata additionalProperties = newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() @@ -780,6 +804,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -850,6 +889,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -878,6 +918,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -912,6 +953,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1471,6 +1513,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1493,6 +1536,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1501,5 +1545,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index 4a73e7f90..5a0bc43cb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newPlanBulkPrice.fixedPriceQuantity invoiceGroupingKey = newPlanBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanBulkPrice.invoicingCycleConfiguration + licenseTypeId = newPlanBulkPrice.licenseTypeId metadata = newPlanBulkPrice.metadata referenceId = newPlanBulkPrice.referenceId additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() @@ -796,6 +820,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -880,6 +919,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -909,6 +949,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -944,6 +985,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1341,6 +1383,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1364,6 +1407,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1373,5 +1417,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index 8eec7d2f0..22e3dcde7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanBulkWithProrationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanBulkWithProrationPrice.licenseTypeId metadata = newPlanBulkWithProrationPrice.metadata referenceId = newPlanBulkWithProrationPrice.referenceId additionalProperties = newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() @@ -805,6 +829,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -889,6 +928,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -918,6 +958,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -953,6 +994,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1739,6 +1781,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1762,6 +1805,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1771,5 +1815,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index 350df983f..15e70001d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newPlanCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newPlanCumulativeGroupedBulkPrice.licenseTypeId metadata = newPlanCumulativeGroupedBulkPrice.metadata referenceId = newPlanCumulativeGroupedBulkPrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1839,6 +1881,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1862,6 +1905,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1871,5 +1915,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 142851c2e..442cbe110 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -500,6 +523,7 @@ private constructor( fixedPriceQuantity = newPlanGroupedAllocationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedAllocationPrice.licenseTypeId metadata = newPlanGroupedAllocationPrice.metadata referenceId = newPlanGroupedAllocationPrice.referenceId additionalProperties = newPlanGroupedAllocationPrice.additionalProperties.toMutableMap() @@ -804,6 +828,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -888,6 +927,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -917,6 +957,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -952,6 +993,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1603,6 +1645,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1626,6 +1669,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1635,5 +1679,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index 75a0a9c54..077a6e138 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedTieredPackagePrice.licenseTypeId metadata = newPlanGroupedTieredPackagePrice.metadata referenceId = newPlanGroupedTieredPackagePrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1831,6 +1873,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1854,6 +1897,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1863,5 +1907,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index 72e129de7..2a742dfc8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -499,6 +522,7 @@ private constructor( fixedPriceQuantity = newPlanGroupedTieredPrice.fixedPriceQuantity invoiceGroupingKey = newPlanGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedTieredPrice.licenseTypeId metadata = newPlanGroupedTieredPrice.metadata referenceId = newPlanGroupedTieredPrice.referenceId additionalProperties = newPlanGroupedTieredPrice.additionalProperties.toMutableMap() @@ -802,6 +826,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -886,6 +925,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -915,6 +955,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -950,6 +991,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1782,6 +1824,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1805,6 +1848,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1814,5 +1858,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index 1e602f6fe..3c7d331ee 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -248,6 +253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -413,6 +426,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newPlanGroupedWithMeteredMinimumPrice.metadata referenceId = newPlanGroupedWithMeteredMinimumPrice.referenceId additionalProperties = @@ -814,6 +838,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -898,6 +937,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -927,6 +967,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -962,6 +1003,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -2221,6 +2263,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2244,6 +2287,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2253,5 +2297,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index 366a7d409..9356a65b2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -481,6 +503,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -508,6 +531,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedWithProratedMinimumPrice.licenseTypeId metadata = newPlanGroupedWithProratedMinimumPrice.metadata referenceId = newPlanGroupedWithProratedMinimumPrice.referenceId additionalProperties = @@ -813,6 +837,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -897,6 +936,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -926,6 +966,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -961,6 +1002,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1605,6 +1647,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1628,6 +1671,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1637,5 +1681,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index e4bfc7ad3..7abab9c21 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newPlanMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newPlanMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixPrice.licenseTypeId metadata = newPlanMatrixPrice.metadata referenceId = newPlanMatrixPrice.referenceId additionalProperties = newPlanMatrixPrice.additionalProperties.toMutableMap() @@ -798,6 +822,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -882,6 +921,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -911,6 +951,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -946,6 +987,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1343,6 +1385,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1366,6 +1409,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1375,5 +1419,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index 874f616fd..a9cfbbf33 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( invoiceGroupingKey = newPlanMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixWithAllocationPrice.licenseTypeId metadata = newPlanMatrixWithAllocationPrice.metadata referenceId = newPlanMatrixWithAllocationPrice.referenceId additionalProperties = @@ -809,6 +833,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -893,6 +932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -922,6 +962,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -957,6 +998,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1354,6 +1396,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1377,6 +1420,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1386,5 +1430,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index 6ab4c5193..3f6f34dba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixWithDisplayNamePrice.licenseTypeId metadata = newPlanMatrixWithDisplayNamePrice.metadata referenceId = newPlanMatrixWithDisplayNamePrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1840,6 +1882,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1863,6 +1906,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1872,5 +1916,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index 7638dffc0..bdd4c2742 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newPlanMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMaxGroupTieredPackagePrice.licenseTypeId metadata = newPlanMaxGroupTieredPackagePrice.metadata referenceId = newPlanMaxGroupTieredPackagePrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1832,6 +1874,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1855,6 +1898,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1864,5 +1908,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt index 3fd53b65b..c0bf6c66b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -477,6 +499,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -499,6 +522,7 @@ private constructor( fixedPriceQuantity = newPlanMinimumCompositePrice.fixedPriceQuantity invoiceGroupingKey = newPlanMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMinimumCompositePrice.licenseTypeId metadata = newPlanMinimumCompositePrice.metadata referenceId = newPlanMinimumCompositePrice.referenceId additionalProperties = newPlanMinimumCompositePrice.additionalProperties.toMutableMap() @@ -803,6 +827,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -887,6 +926,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -916,6 +956,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -951,6 +992,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1554,6 +1596,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1577,6 +1620,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1586,5 +1630,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index e068235e9..1beddbb12 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newPlanPackagePrice.fixedPriceQuantity invoiceGroupingKey = newPlanPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanPackagePrice.licenseTypeId metadata = newPlanPackagePrice.metadata referenceId = newPlanPackagePrice.referenceId additionalProperties = newPlanPackagePrice.additionalProperties.toMutableMap() @@ -798,6 +822,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -882,6 +921,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -911,6 +951,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -946,6 +987,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1343,6 +1385,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1366,6 +1409,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1375,5 +1419,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index b3ad1ea97..e37dd5081 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( invoiceGroupingKey = newPlanPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanPackageWithAllocationPrice.licenseTypeId metadata = newPlanPackageWithAllocationPrice.metadata referenceId = newPlanPackageWithAllocationPrice.referenceId additionalProperties = @@ -809,6 +833,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -893,6 +932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -922,6 +962,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -957,6 +998,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1600,6 +1642,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1623,6 +1666,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1632,5 +1676,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index d1b86cbe6..4b82b5d79 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -513,6 +536,7 @@ private constructor( invoiceGroupingKey = newPlanScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newPlanScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newPlanScalableMatrixWithTieredPricingPrice.metadata referenceId = newPlanScalableMatrixWithTieredPricingPrice.referenceId additionalProperties = @@ -823,6 +847,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -910,6 +949,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -939,6 +979,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -974,6 +1015,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -2180,6 +2222,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2203,6 +2246,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2212,5 +2256,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index b097d84a7..0b1d4b05a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -248,6 +253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -413,6 +426,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newPlanScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newPlanScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newPlanScalableMatrixWithUnitPricingPrice.metadata referenceId = newPlanScalableMatrixWithUnitPricingPrice.referenceId additionalProperties = @@ -815,6 +839,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -902,6 +941,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -931,6 +971,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -966,6 +1007,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -2000,6 +2042,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2023,6 +2066,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2032,5 +2076,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index d0aed316c..1dd6a9e9a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newPlanThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newPlanThresholdTotalAmountPrice.licenseTypeId metadata = newPlanThresholdTotalAmountPrice.metadata referenceId = newPlanThresholdTotalAmountPrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1800,6 +1842,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1823,6 +1866,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1832,5 +1876,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index b08da4b80..c00e7cebf 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -499,6 +522,7 @@ private constructor( fixedPriceQuantity = newPlanTieredPackagePrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPackagePrice.licenseTypeId metadata = newPlanTieredPackagePrice.metadata referenceId = newPlanTieredPackagePrice.referenceId additionalProperties = newPlanTieredPackagePrice.additionalProperties.toMutableMap() @@ -802,6 +826,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -886,6 +925,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -915,6 +955,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -950,6 +991,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1780,6 +1822,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1803,6 +1846,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1812,5 +1856,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index c857fbb47..cb9da28e9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -248,6 +253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -413,6 +426,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newPlanTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPackageWithMinimumPrice.licenseTypeId metadata = newPlanTieredPackageWithMinimumPrice.metadata referenceId = newPlanTieredPackageWithMinimumPrice.referenceId additionalProperties = @@ -814,6 +838,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -898,6 +937,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -927,6 +967,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -962,6 +1003,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1831,6 +1873,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1854,6 +1897,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1863,5 +1907,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 579e9ce80..a0347c200 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newPlanTieredPrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPrice.licenseTypeId metadata = newPlanTieredPrice.metadata referenceId = newPlanTieredPrice.referenceId additionalProperties = newPlanTieredPrice.additionalProperties.toMutableMap() @@ -798,6 +822,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -882,6 +921,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -911,6 +951,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -946,6 +987,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1343,6 +1385,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1366,6 +1409,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1375,5 +1419,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index 16927419a..6fd2d5b5a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanTieredWithMinimumPrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredWithMinimumPrice.licenseTypeId metadata = newPlanTieredWithMinimumPrice.metadata referenceId = newPlanTieredWithMinimumPrice.referenceId additionalProperties = newPlanTieredWithMinimumPrice.additionalProperties.toMutableMap() @@ -805,6 +829,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -889,6 +928,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -918,6 +958,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -953,6 +994,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1868,6 +1910,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1891,6 +1934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1900,5 +1944,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index 670c157ef..cabb07838 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newPlanUnitPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitPrice.licenseTypeId metadata = newPlanUnitPrice.metadata referenceId = newPlanUnitPrice.referenceId additionalProperties = newPlanUnitPrice.additionalProperties.toMutableMap() @@ -796,6 +820,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -880,6 +919,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -909,6 +949,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -944,6 +985,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1341,6 +1383,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1364,6 +1407,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1373,5 +1417,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index 2f83db737..f87746fd6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -477,6 +499,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -499,6 +522,7 @@ private constructor( fixedPriceQuantity = newPlanUnitWithPercentPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitWithPercentPrice.licenseTypeId metadata = newPlanUnitWithPercentPrice.metadata referenceId = newPlanUnitWithPercentPrice.referenceId additionalProperties = newPlanUnitWithPercentPrice.additionalProperties.toMutableMap() @@ -802,6 +826,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -886,6 +925,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -915,6 +955,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -950,6 +991,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1549,6 +1591,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1572,6 +1615,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1581,5 +1625,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index ed0113c20..f117b6d63 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -500,6 +523,7 @@ private constructor( fixedPriceQuantity = newPlanUnitWithProrationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitWithProrationPrice.licenseTypeId metadata = newPlanUnitWithProrationPrice.metadata referenceId = newPlanUnitWithProrationPrice.referenceId additionalProperties = newPlanUnitWithProrationPrice.additionalProperties.toMutableMap() @@ -804,6 +828,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -888,6 +927,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -917,6 +957,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -952,6 +993,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1512,6 +1554,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1535,6 +1578,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1544,5 +1588,5 @@ private constructor( 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index 444fd4b50..d0d774fe6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionBulkPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionBulkPrice.licenseTypeId metadata = newSubscriptionBulkPrice.metadata referenceId = newSubscriptionBulkPrice.referenceId additionalProperties = newSubscriptionBulkPrice.additionalProperties.toMutableMap() @@ -796,6 +820,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -880,6 +919,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -909,6 +949,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -944,6 +985,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1341,6 +1383,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1364,6 +1407,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1373,5 +1417,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index 5d5d26545..65faaefde 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( invoiceGroupingKey = newSubscriptionBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionBulkWithProrationPrice.licenseTypeId metadata = newSubscriptionBulkWithProrationPrice.metadata referenceId = newSubscriptionBulkWithProrationPrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1744,6 +1786,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1767,6 +1810,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1776,5 +1820,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index df7fdbc77..b6b9a185b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -507,6 +530,7 @@ private constructor( invoiceGroupingKey = newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionCumulativeGroupedBulkPrice.licenseTypeId metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId additionalProperties = @@ -811,6 +835,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -895,6 +934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -924,6 +964,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -959,6 +1000,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1840,6 +1882,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1863,6 +1906,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1872,5 +1916,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index 1376a2207..557eb6a52 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedAllocationPrice.licenseTypeId metadata = newSubscriptionGroupedAllocationPrice.metadata referenceId = newSubscriptionGroupedAllocationPrice.referenceId additionalProperties = @@ -809,6 +833,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -893,6 +932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -922,6 +962,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -957,6 +998,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1608,6 +1650,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1631,6 +1674,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1640,5 +1684,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index 8c1259ab5..1199dc9ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -507,6 +530,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedTieredPackagePrice.licenseTypeId metadata = newSubscriptionGroupedTieredPackagePrice.metadata referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId additionalProperties = @@ -811,6 +835,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -895,6 +934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -924,6 +964,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -959,6 +1000,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1832,6 +1874,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1855,6 +1898,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1864,5 +1908,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index a23b3a6b9..64bbd3b7c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedTieredPrice.licenseTypeId metadata = newSubscriptionGroupedTieredPrice.metadata referenceId = newSubscriptionGroupedTieredPrice.referenceId additionalProperties = @@ -808,6 +832,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -892,6 +931,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -921,6 +961,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -956,6 +997,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1788,6 +1830,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1811,6 +1854,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1820,5 +1864,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index d28e9543d..f9dd4fb1d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -248,6 +253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -413,6 +426,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId additionalProperties = @@ -816,6 +840,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -900,6 +939,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -929,6 +969,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -964,6 +1005,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -2223,6 +2265,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2246,6 +2289,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2255,5 +2299,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 61a7ad018..a6bb7ed6b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -481,6 +503,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedWithProratedMinimumPrice.licenseTypeId metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId additionalProperties = @@ -815,6 +839,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -899,6 +938,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -928,6 +968,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -963,6 +1004,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1607,6 +1649,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1630,6 +1673,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1639,5 +1683,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index 1d22f90f4..cbcf69378 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixPrice.licenseTypeId metadata = newSubscriptionMatrixPrice.metadata referenceId = newSubscriptionMatrixPrice.referenceId additionalProperties = newSubscriptionMatrixPrice.additionalProperties.toMutableMap() @@ -798,6 +822,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -882,6 +921,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -911,6 +951,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -946,6 +987,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1343,6 +1385,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1366,6 +1409,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1375,5 +1419,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index f15a1c497..2799770fa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixWithAllocationPrice.licenseTypeId metadata = newSubscriptionMatrixWithAllocationPrice.metadata referenceId = newSubscriptionMatrixWithAllocationPrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1355,6 +1397,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1378,6 +1421,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1387,5 +1431,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index 9ab1f5275..23c6ca196 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -507,6 +530,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixWithDisplayNamePrice.licenseTypeId metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId additionalProperties = @@ -811,6 +835,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -895,6 +934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -924,6 +964,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -959,6 +1000,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1841,6 +1883,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1864,6 +1907,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1873,5 +1917,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index 63cb88da2..582e9847e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -507,6 +530,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMaxGroupTieredPackagePrice.licenseTypeId metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId additionalProperties = @@ -811,6 +835,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -895,6 +934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -924,6 +964,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -959,6 +1000,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1833,6 +1875,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1856,6 +1899,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1865,5 +1909,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt index 9ead49f92..463091d01 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMinimumCompositePrice.licenseTypeId metadata = newSubscriptionMinimumCompositePrice.metadata referenceId = newSubscriptionMinimumCompositePrice.referenceId additionalProperties = @@ -809,6 +833,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -893,6 +932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -922,6 +962,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -957,6 +998,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1560,6 +1602,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1583,6 +1626,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1592,5 +1636,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 4692905c4..ceeb2a9b8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -497,6 +520,7 @@ private constructor( fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionPackagePrice.licenseTypeId metadata = newSubscriptionPackagePrice.metadata referenceId = newSubscriptionPackagePrice.referenceId additionalProperties = newSubscriptionPackagePrice.additionalProperties.toMutableMap() @@ -799,6 +823,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -883,6 +922,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -912,6 +952,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -947,6 +988,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1344,6 +1386,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1367,6 +1410,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1376,5 +1420,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index 0e3c7bd9e..24c262857 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( invoiceGroupingKey = newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionPackageWithAllocationPrice.licenseTypeId metadata = newSubscriptionPackageWithAllocationPrice.metadata referenceId = newSubscriptionPackageWithAllocationPrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1601,6 +1643,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1624,6 +1667,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1633,5 +1677,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index 52ae9f9e8..32ac4358c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -518,6 +541,7 @@ private constructor( newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata referenceId = newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId additionalProperties = @@ -829,6 +853,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -916,6 +955,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -945,6 +985,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -980,6 +1021,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -2186,6 +2228,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2209,6 +2252,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2218,5 +2262,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index 6df670fd9..d63b87944 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -248,6 +253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -413,6 +426,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId additionalProperties = @@ -821,6 +845,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -908,6 +947,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -937,6 +977,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -972,6 +1013,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -2006,6 +2048,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2029,6 +2072,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2038,5 +2082,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index 9f8625e86..87f0b2c01 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -480,6 +502,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -507,6 +530,7 @@ private constructor( invoiceGroupingKey = newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionThresholdTotalAmountPrice.licenseTypeId metadata = newSubscriptionThresholdTotalAmountPrice.metadata referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId additionalProperties = @@ -811,6 +835,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -895,6 +934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -924,6 +964,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -959,6 +1000,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1801,6 +1843,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1824,6 +1867,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1833,5 +1877,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index 3fffe64e6..3926f7a22 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPackagePrice.licenseTypeId metadata = newSubscriptionTieredPackagePrice.metadata referenceId = newSubscriptionTieredPackagePrice.referenceId additionalProperties = @@ -808,6 +832,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -892,6 +931,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -921,6 +961,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -956,6 +997,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1786,6 +1828,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1809,6 +1852,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1818,5 +1862,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 177bca32a..fc4fe683c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -248,6 +253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -413,6 +426,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPackageWithMinimumPrice.licenseTypeId metadata = newSubscriptionTieredPackageWithMinimumPrice.metadata referenceId = newSubscriptionTieredPackageWithMinimumPrice.referenceId additionalProperties = @@ -815,6 +839,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -899,6 +938,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -928,6 +968,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -963,6 +1004,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1832,6 +1874,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1855,6 +1898,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1864,5 +1908,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index aad8a711d..c0d202eff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPrice.licenseTypeId metadata = newSubscriptionTieredPrice.metadata referenceId = newSubscriptionTieredPrice.referenceId additionalProperties = newSubscriptionTieredPrice.additionalProperties.toMutableMap() @@ -798,6 +822,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -882,6 +921,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -911,6 +951,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -946,6 +987,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1343,6 +1385,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1366,6 +1409,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1375,5 +1419,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index 54ec93245..c6a68a970 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -37,6 +37,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -247,6 +252,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -411,6 +424,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredWithMinimumPrice.licenseTypeId metadata = newSubscriptionTieredWithMinimumPrice.metadata referenceId = newSubscriptionTieredWithMinimumPrice.referenceId additionalProperties = @@ -810,6 +834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -894,6 +933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -923,6 +963,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -958,6 +999,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1873,6 +1915,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1896,6 +1939,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1905,5 +1949,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 74787c1d4..a01366cf5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -408,6 +421,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -475,6 +497,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -496,6 +519,7 @@ private constructor( fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitPrice.licenseTypeId metadata = newSubscriptionUnitPrice.metadata referenceId = newSubscriptionUnitPrice.referenceId additionalProperties = newSubscriptionUnitPrice.additionalProperties.toMutableMap() @@ -796,6 +820,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -880,6 +919,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -909,6 +949,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -944,6 +985,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1341,6 +1383,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1364,6 +1407,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1373,5 +1417,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index 7c407f78f..3b1ebbfc6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitWithPercentPrice.licenseTypeId metadata = newSubscriptionUnitWithPercentPrice.metadata referenceId = newSubscriptionUnitWithPercentPrice.referenceId additionalProperties = @@ -808,6 +832,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -892,6 +931,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -921,6 +961,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -956,6 +997,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1555,6 +1597,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1578,6 +1621,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1587,5 +1631,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index 3ef3b34ae..1dfc64687 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -36,6 +36,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -84,6 +85,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -410,6 +423,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -478,6 +500,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( invoiceGroupingKey = newSubscriptionUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitWithProrationPrice.licenseTypeId metadata = newSubscriptionUnitWithProrationPrice.metadata referenceId = newSubscriptionUnitWithProrationPrice.referenceId additionalProperties = @@ -809,6 +833,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -893,6 +932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -922,6 +962,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -957,6 +998,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -1517,6 +1559,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1540,6 +1583,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1549,5 +1593,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 6f2210aaf..f85f65f2d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -2826,6 +2826,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -2884,6 +2885,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -2907,6 +2911,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -3062,6 +3067,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -3231,6 +3244,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3304,6 +3327,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3326,6 +3350,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -3668,6 +3693,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -3757,6 +3797,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -3790,6 +3831,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -3826,6 +3868,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -4806,6 +4849,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -4829,6 +4873,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -4838,7 +4883,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -4861,6 +4906,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -4920,6 +4966,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -4943,6 +4992,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5098,6 +5148,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -5267,6 +5325,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5342,6 +5410,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5365,6 +5434,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -5709,6 +5779,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5798,6 +5883,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -5831,6 +5917,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -5869,6 +5956,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -6575,6 +6663,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -6598,6 +6687,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -6607,7 +6697,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -6631,6 +6721,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6691,6 +6782,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6714,6 +6808,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6871,6 +6966,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -7040,6 +7143,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7117,6 +7230,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7143,6 +7257,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -7494,6 +7609,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7586,6 +7716,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7619,6 +7750,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -7657,6 +7789,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -8273,6 +8406,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8296,6 +8430,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8305,7 +8440,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -8329,6 +8464,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8389,6 +8525,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8412,6 +8551,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8569,6 +8709,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8738,6 +8886,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8815,6 +8973,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8841,6 +9000,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -9192,6 +9352,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9284,6 +9459,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9317,6 +9493,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -9355,6 +9532,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -9978,6 +10156,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10001,6 +10180,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10010,7 +10190,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -10033,6 +10213,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10091,6 +10272,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10114,6 +10298,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10268,6 +10453,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10436,6 +10629,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10509,6 +10712,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10530,6 +10734,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -10872,6 +11077,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10961,6 +11181,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -10994,6 +11215,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -11030,6 +11252,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -11493,6 +11716,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -11516,6 +11740,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -11525,7 +11750,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -11548,6 +11773,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -11606,6 +11832,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -11629,6 +11858,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -11784,6 +12014,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -11952,6 +12190,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12025,6 +12273,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12046,6 +12295,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -12388,6 +12638,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12477,6 +12742,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -12510,6 +12776,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -12546,6 +12813,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -13116,6 +13384,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13139,6 +13408,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13148,7 +13418,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 4c068c4a9..6b2f21d63 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1164,6 +1164,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -1240,6 +1241,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -1269,6 +1273,7 @@ private constructor( replacesPriceId, unitConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -1466,6 +1471,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -1719,6 +1733,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1801,6 +1824,7 @@ private constructor( private var unitConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitPrice: UnitPrice) = apply { @@ -1832,6 +1856,7 @@ private constructor( replacesPriceId = unitPrice.replacesPriceId unitConfig = unitPrice.unitConfig dimensionalPriceConfiguration = unitPrice.dimensionalPriceConfiguration + licenseType = unitPrice.licenseType additionalProperties = unitPrice.additionalProperties.toMutableMap() } @@ -2375,6 +2400,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2463,6 +2507,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitConfig", unitConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -2506,6 +2551,7 @@ private constructor( replacesPriceId() unitConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -2551,7 +2597,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (unitConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3614,6 +3661,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3648,6 +3951,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -3681,6 +3985,7 @@ private constructor( replacesPriceId, unitConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -3688,7 +3993,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Tiered @@ -3722,6 +4027,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -3798,6 +4104,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -3827,6 +4136,7 @@ private constructor( replacesPriceId, tieredConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -4024,6 +4334,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -4278,6 +4597,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4360,6 +4688,7 @@ private constructor( private var tieredConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tiered: Tiered) = apply { @@ -4391,6 +4720,7 @@ private constructor( replacesPriceId = tiered.replacesPriceId tieredConfig = tiered.tieredConfig dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + licenseType = tiered.licenseType additionalProperties = tiered.additionalProperties.toMutableMap() } @@ -4934,6 +5264,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5022,6 +5371,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredConfig", tieredConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -5065,6 +5415,7 @@ private constructor( replacesPriceId() tieredConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -5110,7 +5461,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (tieredConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6173,6 +6525,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6207,6 +6815,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -6240,6 +6849,7 @@ private constructor( replacesPriceId, tieredConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -6247,7 +6857,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Bulk @@ -6281,6 +6891,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -6357,6 +6968,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -6386,6 +7000,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -6583,6 +7198,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -6836,6 +7460,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -6918,6 +7551,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bulk: Bulk) = apply { @@ -6949,6 +7583,7 @@ private constructor( priceType = bulk.priceType replacesPriceId = bulk.replacesPriceId dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + licenseType = bulk.licenseType additionalProperties = bulk.additionalProperties.toMutableMap() } @@ -7492,6 +8127,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7580,6 +8234,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -7623,6 +8278,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -7668,7 +8324,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8731,6 +9388,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -8765,6 +9678,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -8798,6 +9712,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -8805,7 +9720,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithFilters @@ -8839,6 +9754,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -8915,6 +9831,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -8944,6 +9863,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -9142,6 +10062,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -9396,6 +10325,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -9478,6 +10416,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bulkWithFilters: BulkWithFilters) = apply { @@ -9510,6 +10449,7 @@ private constructor( priceType = bulkWithFilters.priceType replacesPriceId = bulkWithFilters.replacesPriceId dimensionalPriceConfiguration = bulkWithFilters.dimensionalPriceConfiguration + licenseType = bulkWithFilters.licenseType additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -10055,6 +10995,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10143,6 +11102,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -10186,6 +11146,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -10231,7 +11192,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -11966,6 +12928,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12000,6 +13218,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -12033,6 +13252,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -12040,7 +13260,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Package @@ -12074,6 +13294,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -12150,6 +13371,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -12179,6 +13403,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -12376,6 +13601,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -12630,6 +13864,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -12712,6 +13955,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(package_: Package) = apply { @@ -12743,6 +13987,7 @@ private constructor( priceType = package_.priceType replacesPriceId = package_.replacesPriceId dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + licenseType = package_.licenseType additionalProperties = package_.additionalProperties.toMutableMap() } @@ -13287,6 +14532,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13375,6 +14639,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -13418,6 +14683,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -13463,7 +14729,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -14526,6 +15793,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -14560,6 +16083,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -14593,6 +16117,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -14600,7 +16125,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Matrix @@ -14634,6 +16159,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -14710,6 +16236,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -14739,6 +16268,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -14936,6 +16466,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -15190,6 +16729,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -15272,6 +16820,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrix: Matrix) = apply { @@ -15303,6 +16852,7 @@ private constructor( priceType = matrix.priceType replacesPriceId = matrix.replacesPriceId dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + licenseType = matrix.licenseType additionalProperties = matrix.additionalProperties.toMutableMap() } @@ -15846,6 +17396,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15934,6 +17503,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -15977,6 +17547,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -16022,7 +17593,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17085,6 +18657,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17119,6 +18947,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -17152,6 +18981,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -17159,7 +18989,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ThresholdTotalAmount @@ -17193,6 +19023,7 @@ private constructor( private val replacesPriceId: JsonField, private val thresholdTotalAmountConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -17269,6 +19100,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -17298,6 +19132,7 @@ private constructor( replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -17496,6 +19331,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -17751,6 +19595,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -17833,6 +19686,7 @@ private constructor( private var thresholdTotalAmountConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { @@ -17865,6 +19719,7 @@ private constructor( replacesPriceId = thresholdTotalAmount.replacesPriceId thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig dimensionalPriceConfiguration = thresholdTotalAmount.dimensionalPriceConfiguration + licenseType = thresholdTotalAmount.licenseType additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } @@ -18409,6 +20264,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -18497,6 +20371,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -18540,6 +20415,7 @@ private constructor( replacesPriceId() thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -18585,7 +20461,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -20103,6 +21980,262 @@ private constructor( "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20137,6 +22270,7 @@ private constructor( replacesPriceId == other.replacesPriceId && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -20170,6 +22304,7 @@ private constructor( replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -20177,7 +22312,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackage @@ -20211,6 +22346,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredPackageConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -20287,6 +22423,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -20316,6 +22455,7 @@ private constructor( replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -20514,6 +22654,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -20768,6 +22917,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -20850,6 +23008,7 @@ private constructor( private var tieredPackageConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackage: TieredPackage) = apply { @@ -20882,6 +23041,7 @@ private constructor( replacesPriceId = tieredPackage.replacesPriceId tieredPackageConfig = tieredPackage.tieredPackageConfig dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + licenseType = tieredPackage.licenseType additionalProperties = tieredPackage.additionalProperties.toMutableMap() } @@ -21426,6 +23586,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21514,6 +23693,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredPackageConfig", tieredPackageConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -21557,6 +23737,7 @@ private constructor( replacesPriceId() tieredPackageConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -21602,7 +23783,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (tieredPackageConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23111,6 +25293,262 @@ private constructor( "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23145,6 +25583,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -23178,6 +25617,7 @@ private constructor( replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -23185,7 +25625,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithMinimum @@ -23219,6 +25659,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -23295,6 +25736,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -23324,6 +25768,7 @@ private constructor( replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -23522,6 +25967,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -23776,6 +26230,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -23858,6 +26321,7 @@ private constructor( private var tieredWithMinimumConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { @@ -23890,6 +26354,7 @@ private constructor( replacesPriceId = tieredWithMinimum.replacesPriceId tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration + licenseType = tieredWithMinimum.licenseType additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } @@ -24434,6 +26899,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24522,6 +27006,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -24565,6 +27050,7 @@ private constructor( replacesPriceId() tieredWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -24610,7 +27096,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -26203,6 +28690,262 @@ private constructor( "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26237,6 +28980,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -26270,6 +29014,7 @@ private constructor( replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -26277,7 +29022,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTiered @@ -26311,6 +29056,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -26387,6 +29133,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -26416,6 +29165,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -26614,6 +29364,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -26868,6 +29627,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -26950,6 +29718,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTiered: GroupedTiered) = apply { @@ -26982,6 +29751,7 @@ private constructor( priceType = groupedTiered.priceType replacesPriceId = groupedTiered.replacesPriceId dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + licenseType = groupedTiered.licenseType additionalProperties = groupedTiered.additionalProperties.toMutableMap() } @@ -27526,6 +30296,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -27614,6 +30403,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -27657,6 +30447,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -27702,7 +30493,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -29211,6 +32003,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29245,6 +32293,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -29278,6 +32327,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -29285,7 +32335,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackageWithMinimum @@ -29319,6 +32369,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredPackageWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -29396,6 +32447,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -29425,6 +32479,7 @@ private constructor( replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -29623,6 +32678,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -29878,6 +32942,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -29961,6 +33034,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { @@ -29995,6 +33069,7 @@ private constructor( tieredPackageWithMinimum.tieredPackageWithMinimumConfig dimensionalPriceConfiguration = tieredPackageWithMinimum.dimensionalPriceConfiguration + licenseType = tieredPackageWithMinimum.licenseType additionalProperties = tieredPackageWithMinimum.additionalProperties.toMutableMap() } @@ -30540,6 +33615,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -30628,6 +33722,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -30671,6 +33766,7 @@ private constructor( replacesPriceId() tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -30718,7 +33814,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -32266,6 +35363,262 @@ private constructor( "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -32300,6 +35653,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -32333,6 +35687,7 @@ private constructor( replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -32340,7 +35695,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class PackageWithAllocation @@ -32374,6 +35729,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -32450,6 +35806,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -32479,6 +35838,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -32677,6 +36037,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -32932,6 +36301,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -33014,6 +36392,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(packageWithAllocation: PackageWithAllocation) = apply { @@ -33046,6 +36425,7 @@ private constructor( priceType = packageWithAllocation.priceType replacesPriceId = packageWithAllocation.replacesPriceId dimensionalPriceConfiguration = packageWithAllocation.dimensionalPriceConfiguration + licenseType = packageWithAllocation.licenseType additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } @@ -33591,6 +36971,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -33679,6 +37078,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -33722,6 +37122,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -33767,7 +37168,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35088,6 +38490,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35122,6 +38780,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -35155,6 +38814,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -35162,7 +38822,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithPercent @@ -35196,6 +38856,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitWithPercentConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -35272,6 +38933,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -35301,6 +38965,7 @@ private constructor( replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -35499,6 +39164,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -35753,6 +39427,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -35835,6 +39518,7 @@ private constructor( private var unitWithPercentConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithPercent: UnitWithPercent) = apply { @@ -35867,6 +39551,7 @@ private constructor( replacesPriceId = unitWithPercent.replacesPriceId unitWithPercentConfig = unitWithPercent.unitWithPercentConfig dimensionalPriceConfiguration = unitWithPercent.dimensionalPriceConfiguration + licenseType = unitWithPercent.licenseType additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } @@ -36412,6 +40097,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -36500,6 +40204,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitWithPercentConfig", unitWithPercentConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -36543,6 +40248,7 @@ private constructor( replacesPriceId() unitWithPercentConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -36588,7 +40294,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -37865,6 +41572,262 @@ private constructor( "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -37899,6 +41862,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -37932,6 +41896,7 @@ private constructor( replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -37939,7 +41904,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithAllocation @@ -37973,6 +41938,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -38049,6 +42015,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -38078,6 +42047,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -38276,6 +42246,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -38531,6 +42510,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -38613,6 +42601,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { @@ -38645,6 +42634,7 @@ private constructor( priceType = matrixWithAllocation.priceType replacesPriceId = matrixWithAllocation.replacesPriceId dimensionalPriceConfiguration = matrixWithAllocation.dimensionalPriceConfiguration + licenseType = matrixWithAllocation.licenseType additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() } @@ -39189,6 +43179,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -39277,6 +43286,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -39320,6 +43330,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -39365,7 +43376,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -40428,6 +44440,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -40462,6 +44730,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -40495,6 +44764,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -40502,7 +44772,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -40536,6 +44806,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -40612,6 +44883,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -40641,6 +44915,7 @@ private constructor( replacesPriceId, tieredWithProrationConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -40839,6 +45114,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -41094,6 +45378,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -41176,6 +45469,7 @@ private constructor( private var tieredWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tieredWithProration: TieredWithProration) = apply { @@ -41208,6 +45502,7 @@ private constructor( replacesPriceId = tieredWithProration.replacesPriceId tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration + licenseType = tieredWithProration.licenseType additionalProperties = tieredWithProration.additionalProperties.toMutableMap() } @@ -41752,6 +46047,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -41840,6 +46154,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -41883,6 +46198,7 @@ private constructor( replacesPriceId() tieredWithProrationConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -41928,7 +46244,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -43395,6 +47712,262 @@ private constructor( "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -43429,6 +48002,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -43462,6 +48036,7 @@ private constructor( replacesPriceId, tieredWithProrationConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -43469,7 +48044,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithProration @@ -43503,6 +48078,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -43579,6 +48155,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -43608,6 +48187,7 @@ private constructor( replacesPriceId, unitWithProrationConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -43806,6 +48386,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -44060,6 +48649,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -44142,6 +48740,7 @@ private constructor( private var unitWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(unitWithProration: UnitWithProration) = apply { @@ -44174,6 +48773,7 @@ private constructor( replacesPriceId = unitWithProration.replacesPriceId unitWithProrationConfig = unitWithProration.unitWithProrationConfig dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration + licenseType = unitWithProration.licenseType additionalProperties = unitWithProration.additionalProperties.toMutableMap() } @@ -44718,6 +49318,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -44806,6 +49425,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -44849,6 +49469,7 @@ private constructor( replacesPriceId() unitWithProrationConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -44894,7 +49515,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -46129,6 +50751,262 @@ private constructor( "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -46163,6 +51041,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -46196,6 +51075,7 @@ private constructor( replacesPriceId, unitWithProrationConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -46203,7 +51083,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedAllocation @@ -46237,6 +51117,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -46313,6 +51194,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -46342,6 +51226,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -46540,6 +51425,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -46794,6 +51688,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -46876,6 +51779,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedAllocation: GroupedAllocation) = apply { @@ -46908,6 +51812,7 @@ private constructor( priceType = groupedAllocation.priceType replacesPriceId = groupedAllocation.replacesPriceId dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration + licenseType = groupedAllocation.licenseType additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } @@ -47452,6 +52357,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -47540,6 +52464,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -47583,6 +52508,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -47628,7 +52554,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -48957,6 +53884,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -48991,6 +54174,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -49024,6 +54208,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -49031,7 +54216,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithProration @@ -49065,6 +54250,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -49141,6 +54327,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -49170,6 +54359,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -49368,6 +54558,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -49622,6 +54821,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -49704,6 +54912,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bulkWithProration: BulkWithProration) = apply { @@ -49736,6 +54945,7 @@ private constructor( priceType = bulkWithProration.priceType replacesPriceId = bulkWithProration.replacesPriceId dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration + licenseType = bulkWithProration.licenseType additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } @@ -50280,6 +55490,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -50368,6 +55597,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -50411,6 +55641,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -50456,7 +55687,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -51916,6 +57148,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -51950,6 +57438,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -51983,6 +57472,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -51990,7 +57480,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithProratedMinimum @@ -52024,6 +57514,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -52101,6 +57592,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -52130,6 +57624,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -52328,6 +57823,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -52583,6 +58087,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -52668,6 +58181,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { @@ -52702,6 +58216,7 @@ private constructor( replacesPriceId = groupedWithProratedMinimum.replacesPriceId dimensionalPriceConfiguration = groupedWithProratedMinimum.dimensionalPriceConfiguration + licenseType = groupedWithProratedMinimum.licenseType additionalProperties = groupedWithProratedMinimum.additionalProperties.toMutableMap() } @@ -53248,6 +58763,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -53339,6 +58873,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -53382,6 +58917,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -53429,7 +58965,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -54750,6 +60287,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -54784,6 +60577,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -54817,6 +60611,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -54824,7 +60619,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithMeteredMinimum @@ -54858,6 +60653,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -54935,6 +60731,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -54964,6 +60763,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -55162,6 +60962,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -55417,6 +61226,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -55502,6 +61320,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { @@ -55536,6 +61355,7 @@ private constructor( replacesPriceId = groupedWithMeteredMinimum.replacesPriceId dimensionalPriceConfiguration = groupedWithMeteredMinimum.dimensionalPriceConfiguration + licenseType = groupedWithMeteredMinimum.licenseType additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() } @@ -56081,6 +61901,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -56172,6 +62011,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -56215,6 +62055,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -56262,7 +62103,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -58210,6 +64052,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -58244,6 +64342,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -58277,6 +64376,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -58284,7 +64384,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -58318,6 +64418,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -58395,6 +64496,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -58424,6 +64528,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -58622,6 +64727,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -58877,6 +64991,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -58962,6 +65085,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { @@ -58997,6 +65121,7 @@ private constructor( replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId dimensionalPriceConfiguration = groupedWithMinMaxThresholds.dimensionalPriceConfiguration + licenseType = groupedWithMinMaxThresholds.licenseType additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } @@ -59543,6 +65668,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -59634,6 +65778,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -59677,6 +65822,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -59724,7 +65870,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -61107,6 +67254,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -61141,6 +67544,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -61174,6 +67578,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -61181,7 +67586,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithDisplayName @@ -61215,6 +67620,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -61291,6 +67697,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -61320,6 +67729,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -61518,6 +67928,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -61773,6 +68192,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -61855,6 +68283,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { @@ -61887,6 +68316,7 @@ private constructor( priceType = matrixWithDisplayName.priceType replacesPriceId = matrixWithDisplayName.replacesPriceId dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration + licenseType = matrixWithDisplayName.licenseType additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } @@ -62432,6 +68862,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -62520,6 +68969,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -62563,6 +69013,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -62608,7 +69059,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -64168,6 +70620,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -64202,6 +70910,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -64235,6 +70944,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -64242,7 +70952,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTieredPackage @@ -64276,6 +70986,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -64352,6 +71063,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -64381,6 +71095,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -64579,6 +71294,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -64834,6 +71558,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -64916,6 +71649,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { @@ -64948,6 +71682,7 @@ private constructor( priceType = groupedTieredPackage.priceType replacesPriceId = groupedTieredPackage.replacesPriceId dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration + licenseType = groupedTieredPackage.licenseType additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } @@ -65492,6 +72227,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -65580,6 +72334,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -65623,6 +72378,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -65668,7 +72424,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -67220,6 +73977,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -67254,6 +74267,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -67287,6 +74301,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -67294,7 +74309,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MaxGroupTieredPackage @@ -67328,6 +74343,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -67404,6 +74420,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -67433,6 +74452,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -67631,6 +74651,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -67886,6 +74915,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -67968,6 +75006,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { @@ -68000,6 +75039,7 @@ private constructor( priceType = maxGroupTieredPackage.priceType replacesPriceId = maxGroupTieredPackage.replacesPriceId dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration + licenseType = maxGroupTieredPackage.licenseType additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } @@ -68545,6 +75585,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -68633,6 +75692,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -68676,6 +75736,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -68721,7 +75782,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -70276,6 +77338,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -70310,6 +77628,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -70343,6 +77662,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -70350,7 +77670,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ScalableMatrixWithUnitPricing @@ -70385,6 +77705,7 @@ private constructor( private val scalableMatrixWithUnitPricingConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -70462,6 +77783,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -70491,6 +77815,7 @@ private constructor( replacesPriceId, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -70691,6 +78016,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -70946,6 +78280,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -71031,6 +78374,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = @@ -71070,6 +78414,7 @@ private constructor( scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig dimensionalPriceConfiguration = scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + licenseType = scalableMatrixWithUnitPricing.licenseType additionalProperties = scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } @@ -71621,6 +78966,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -71712,6 +79076,7 @@ private constructor( scalableMatrixWithUnitPricingConfig, ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -71755,6 +79120,7 @@ private constructor( replacesPriceId() scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -71802,7 +79168,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -73517,6 +80884,262 @@ private constructor( "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -73551,6 +81174,7 @@ private constructor( replacesPriceId == other.replacesPriceId && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -73584,6 +81208,7 @@ private constructor( replacesPriceId, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -73591,7 +81216,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ScalableMatrixWithTieredPricing @@ -73626,6 +81251,7 @@ private constructor( private val scalableMatrixWithTieredPricingConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -73704,6 +81330,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -73733,6 +81362,7 @@ private constructor( replacesPriceId, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -73933,6 +81563,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -74188,6 +81827,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -74273,6 +81921,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = @@ -74312,6 +81961,7 @@ private constructor( scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig dimensionalPriceConfiguration = scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + licenseType = scalableMatrixWithTieredPricing.licenseType additionalProperties = scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } @@ -74864,6 +82514,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -74955,6 +82624,7 @@ private constructor( scalableMatrixWithTieredPricingConfig, ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -74998,6 +82668,7 @@ private constructor( replacesPriceId() scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -75045,7 +82716,8 @@ private constructor( (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -76929,6 +84601,262 @@ private constructor( "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -76964,6 +84892,7 @@ private constructor( scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -76997,6 +84926,7 @@ private constructor( replacesPriceId, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -77004,7 +84934,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class CumulativeGroupedBulk @@ -77038,6 +84968,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -77114,6 +85045,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -77143,6 +85077,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -77341,6 +85276,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -77596,6 +85540,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -77678,6 +85631,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { @@ -77710,6 +85664,7 @@ private constructor( priceType = cumulativeGroupedBulk.priceType replacesPriceId = cumulativeGroupedBulk.replacesPriceId dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + licenseType = cumulativeGroupedBulk.licenseType additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } @@ -78255,6 +86210,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -78343,6 +86317,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -78386,6 +86361,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -78431,7 +86407,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -79984,6 +87961,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -80018,6 +88251,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -80051,6 +88285,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -80058,7 +88293,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -80092,6 +88327,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -80169,6 +88405,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -80198,6 +88437,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -80396,6 +88636,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -80651,6 +88900,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -80736,6 +88994,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { @@ -80771,6 +89030,7 @@ private constructor( replacesPriceId = cumulativeGroupedAllocation.replacesPriceId dimensionalPriceConfiguration = cumulativeGroupedAllocation.dimensionalPriceConfiguration + licenseType = cumulativeGroupedAllocation.licenseType additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() } @@ -81317,6 +89577,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -81408,6 +89687,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -81451,6 +89731,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -81498,7 +89779,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -82698,20 +90980,402 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + val COMPOSITE_PRICE = of("composite_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } + id() + groupingKey() + name() validated = true } @@ -82730,156 +91394,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val USAGE_PRICE = of("usage_price") - - val FIXED_PRICE = of("fixed_price") - - val COMPOSITE_PRICE = of("composite_price") - - fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = hashCode - override fun toString() = value.toString() + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -82916,6 +91454,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -82949,6 +91488,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -82956,7 +91496,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MinimumComposite @@ -82990,6 +91530,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -83066,6 +91607,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -83095,6 +91639,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -83293,6 +91838,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -83547,6 +92101,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -83629,6 +92192,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(minimumComposite: MinimumComposite) = apply { @@ -83661,6 +92225,7 @@ private constructor( priceType = minimumComposite.priceType replacesPriceId = minimumComposite.replacesPriceId dimensionalPriceConfiguration = minimumComposite.dimensionalPriceConfiguration + licenseType = minimumComposite.licenseType additionalProperties = minimumComposite.additionalProperties.toMutableMap() } @@ -84206,6 +92771,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -84294,6 +92878,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -84337,6 +92922,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -84382,7 +92968,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -85659,6 +94246,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -85693,6 +94536,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -85726,6 +94570,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -85733,7 +94578,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Percent @@ -85767,6 +94612,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -85843,6 +94689,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -85872,6 +94721,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -86069,6 +94919,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -86323,6 +95182,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -86405,6 +95273,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(percent: Percent) = apply { @@ -86436,6 +95305,7 @@ private constructor( priceType = percent.priceType replacesPriceId = percent.replacesPriceId dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + licenseType = percent.licenseType additionalProperties = percent.additionalProperties.toMutableMap() } @@ -86980,6 +95850,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -87068,6 +95957,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -87111,6 +96001,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -87156,7 +96047,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -88186,32 +97078,416 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val USAGE_PRICE = of("usage_price") + + val FIXED_PRICE = of("fixed_price") + + val COMPOSITE_PRICE = of("composite_price") + + fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .id() + * .groupingKey() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - percent() + id() + groupingKey() + name() validated = true } @@ -88229,159 +97505,31 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - val USAGE_PRICE = of("usage_price") - - val FIXED_PRICE = of("fixed_price") - - val COMPOSITE_PRICE = of("composite_price") - - fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString() ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -88418,6 +97566,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -88451,6 +97600,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -88458,7 +97608,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class EventOutput @@ -88492,6 +97642,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -88568,6 +97719,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -88597,6 +97751,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -88795,6 +97950,15 @@ private constructor( fun dimensionalPriceConfiguration(): DimensionalPriceConfiguration? = dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): LicenseType? = licenseType.getNullable("license_type") + /** * Returns the raw JSON value of [id]. * @@ -89049,6 +98213,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -89131,6 +98304,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventOutput: EventOutput) = apply { @@ -89162,6 +98336,7 @@ private constructor( priceType = eventOutput.priceType replacesPriceId = eventOutput.replacesPriceId dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + licenseType = eventOutput.licenseType additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -89706,6 +98881,25 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -89794,6 +98988,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -89837,6 +99032,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration()?.validate() + licenseType()?.validate() validated = true } @@ -89882,7 +99078,8 @@ private constructor( (if (planPhaseOrder.asKnown() == null) 0 else 1) + (priceType.asKnown()?.validity() ?: 0) + (if (replacesPriceId.asKnown() == null) 0 else 1) + - (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (licenseType.asKnown()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -91215,6 +100412,262 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91249,6 +100702,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -91282,6 +100736,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -91289,6 +100744,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index b9f2d8116..f020ddcdc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -1607,6 +1607,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -1660,6 +1661,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -1680,6 +1684,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -1831,6 +1836,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -1983,6 +1996,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -2045,6 +2068,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2065,6 +2089,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -2395,6 +2420,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -2467,6 +2507,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -2499,6 +2540,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -2534,6 +2576,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -3499,6 +3542,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -3521,6 +3565,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -3529,7 +3574,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -3552,6 +3597,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3606,6 +3652,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3626,6 +3675,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -3779,6 +3829,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -3932,6 +3990,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3997,6 +4065,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4022,6 +4091,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -4358,6 +4428,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -4433,6 +4518,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -4465,6 +4551,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -4502,6 +4589,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -5107,6 +5195,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -5129,6 +5218,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -5137,7 +5227,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -5160,6 +5250,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -5214,6 +5305,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5234,6 +5328,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5387,6 +5482,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -5540,6 +5643,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5605,6 +5718,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5630,6 +5744,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -5966,6 +6081,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -6041,6 +6171,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -6073,6 +6204,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -6110,6 +6242,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6723,6 +6856,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6745,6 +6879,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6753,7 +6888,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -6775,6 +6910,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6828,6 +6964,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6848,6 +6987,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -6998,6 +7138,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -7150,6 +7298,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7212,6 +7370,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7232,6 +7391,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -7561,6 +7721,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7633,6 +7808,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7665,6 +7841,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -7700,6 +7877,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8151,6 +8329,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8173,6 +8352,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8181,7 +8361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -8203,6 +8383,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8256,6 +8437,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8276,6 +8460,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8427,6 +8612,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8579,6 +8772,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8641,6 +8844,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8661,6 +8865,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -8990,6 +9195,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9062,6 +9282,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9094,6 +9315,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -9129,6 +9351,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9685,6 +9908,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -9707,6 +9931,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -9715,7 +9940,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index 4c3b960c7..b3b4a249e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -2549,6 +2549,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -2606,6 +2607,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -2626,6 +2630,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -2780,6 +2785,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -2940,6 +2953,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3004,6 +3027,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3025,6 +3049,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -3363,6 +3388,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -3435,6 +3475,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -3467,6 +3508,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -3502,6 +3544,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -4481,6 +4524,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -4503,6 +4547,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -4511,7 +4556,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -4535,6 +4580,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -4594,6 +4640,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -4614,6 +4663,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -4770,6 +4820,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -4930,6 +4988,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -4998,6 +5066,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5023,6 +5092,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -5370,6 +5440,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5445,6 +5530,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -5477,6 +5563,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -5514,6 +5601,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6129,6 +6217,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6151,6 +6240,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6159,7 +6249,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -6183,6 +6273,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6242,6 +6333,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6262,6 +6356,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -6418,6 +6513,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -6578,6 +6681,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6646,6 +6759,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6671,6 +6785,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -7018,6 +7133,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7093,6 +7223,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7125,6 +7256,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -7162,6 +7294,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -7784,6 +7917,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -7806,6 +7940,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -7814,7 +7949,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -7837,6 +7972,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -7894,6 +8030,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7914,6 +8053,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8067,6 +8207,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8226,6 +8374,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8290,6 +8448,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8310,6 +8469,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -8648,6 +8808,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8720,6 +8895,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -8752,6 +8928,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -8787,6 +8964,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9249,6 +9427,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -9271,6 +9450,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -9279,7 +9459,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -9302,6 +9482,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -9359,6 +9540,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9379,6 +9563,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -9533,6 +9718,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -9692,6 +9885,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9756,6 +9959,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9776,6 +9980,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -10114,6 +10319,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10186,6 +10406,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -10218,6 +10439,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -10253,6 +10475,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -10822,6 +11045,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10844,6 +11068,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10852,7 +11077,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index 4d4dded67..f0c641cdb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -3084,6 +3084,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3141,6 +3142,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3161,6 +3165,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -3315,6 +3320,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -3475,6 +3488,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3539,6 +3562,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3560,6 +3584,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -3898,6 +3923,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -3970,6 +4010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -4002,6 +4043,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -4037,6 +4079,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -5016,6 +5059,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -5038,6 +5082,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -5046,7 +5091,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -5070,6 +5115,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -5129,6 +5175,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5149,6 +5198,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5305,6 +5355,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -5465,6 +5523,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5533,6 +5601,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5558,6 +5627,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -5905,6 +5975,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5980,6 +6065,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -6012,6 +6098,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -6049,6 +6136,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6664,6 +6752,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6686,6 +6775,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6694,7 +6784,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -6718,6 +6808,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6777,6 +6868,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6797,6 +6891,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -6953,6 +7048,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -7113,6 +7216,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7181,6 +7294,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7206,6 +7320,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -7553,6 +7668,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7628,6 +7758,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7660,6 +7791,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -7697,6 +7829,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8319,6 +8452,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8341,6 +8475,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8349,7 +8484,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -8372,6 +8507,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8429,6 +8565,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8449,6 +8588,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8602,6 +8742,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8761,6 +8909,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8825,6 +8983,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8845,6 +9004,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -9183,6 +9343,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9255,6 +9430,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9287,6 +9463,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -9322,6 +9499,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9784,6 +9962,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -9806,6 +9985,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -9814,7 +9994,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -9837,6 +10017,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -9894,6 +10075,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9914,6 +10098,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -10068,6 +10253,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10227,6 +10420,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10291,6 +10494,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10311,6 +10515,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -10649,6 +10854,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10721,6 +10941,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -10753,6 +10974,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -10788,6 +11010,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11357,6 +11580,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11379,6 +11603,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11387,7 +11612,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index d2bc194ed..228368eac 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -6163,6 +6163,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6221,6 +6222,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6244,6 +6248,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6399,6 +6404,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -6568,6 +6581,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6641,6 +6664,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6663,6 +6687,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -7005,6 +7030,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7094,6 +7134,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7127,6 +7168,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -7163,6 +7205,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -8143,6 +8186,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8166,6 +8210,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8175,7 +8220,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -8198,6 +8243,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8257,6 +8303,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8280,6 +8329,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8435,6 +8485,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8604,6 +8662,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8679,6 +8747,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8702,6 +8771,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -9046,6 +9116,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9135,6 +9220,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9168,6 +9254,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -9206,6 +9293,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -9912,6 +10000,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -9935,6 +10024,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -9944,7 +10034,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -9968,6 +10058,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10028,6 +10119,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10051,6 +10145,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10208,6 +10303,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10377,6 +10480,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10454,6 +10567,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10480,6 +10594,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -10831,6 +10946,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10923,6 +11053,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -10956,6 +11087,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -10994,6 +11126,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -11610,6 +11743,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -11633,6 +11767,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -11642,7 +11777,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -11666,6 +11801,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -11726,6 +11862,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -11749,6 +11888,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -11906,6 +12046,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -12075,6 +12223,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12152,6 +12310,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12178,6 +12337,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -12529,6 +12689,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12621,6 +12796,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -12654,6 +12830,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -12692,6 +12869,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -13315,6 +13493,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13338,6 +13517,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13347,7 +13527,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -13370,6 +13550,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -13428,6 +13609,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -13451,6 +13635,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -13605,6 +13790,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -13773,6 +13966,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -13846,6 +14049,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -13867,6 +14071,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -14209,6 +14414,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -14298,6 +14518,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -14331,6 +14552,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -14367,6 +14589,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -14830,6 +15053,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14853,6 +15077,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -14862,7 +15087,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -14885,6 +15110,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -14943,6 +15169,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -14966,6 +15195,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -15121,6 +15351,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -15289,6 +15527,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -15362,6 +15610,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -15383,6 +15632,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -15725,6 +15975,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -15814,6 +16079,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -15847,6 +16113,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -15883,6 +16150,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -16453,6 +16721,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -16476,6 +16745,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -16485,7 +16755,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -19697,6 +19967,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -19755,6 +20026,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -19778,6 +20052,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -19933,6 +20208,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -20102,6 +20385,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -20175,6 +20468,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -20197,6 +20491,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -20539,6 +20834,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -20628,6 +20938,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -20661,6 +20972,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -20697,6 +21009,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -21677,6 +21990,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21700,6 +22014,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21709,7 +22024,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -21732,6 +22047,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21791,6 +22107,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -21814,6 +22133,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21969,6 +22289,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -22138,6 +22466,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -22213,6 +22551,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -22236,6 +22575,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -22580,6 +22920,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22669,6 +23024,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22702,6 +23058,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -22740,6 +23097,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -23446,6 +23804,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23469,6 +23828,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23478,7 +23838,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -23502,6 +23862,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23562,6 +23923,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23585,6 +23949,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23742,6 +24107,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -23911,6 +24284,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23988,6 +24371,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -24014,6 +24398,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -24365,6 +24750,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24457,6 +24857,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24490,6 +24891,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -24528,6 +24930,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -25144,6 +25547,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -25167,6 +25571,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -25176,7 +25581,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -25200,6 +25605,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -25260,6 +25666,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -25283,6 +25692,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25440,6 +25850,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -25609,6 +26027,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25686,6 +26114,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25712,6 +26141,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -26063,6 +26493,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -26155,6 +26600,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -26188,6 +26634,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -26226,6 +26673,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -26849,6 +27297,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26872,6 +27321,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26881,7 +27331,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -26904,6 +27354,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26962,6 +27413,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26985,6 +27439,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -27139,6 +27594,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -27307,6 +27770,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -27380,6 +27853,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -27401,6 +27875,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -27743,6 +28218,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27832,6 +28322,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27865,6 +28356,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -27901,6 +28393,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -28364,6 +28857,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28387,6 +28881,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28396,7 +28891,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -28419,6 +28914,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -28477,6 +28973,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -28500,6 +28999,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -28655,6 +29155,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -28823,6 +29331,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -28896,6 +29414,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -28917,6 +29436,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -29259,6 +29779,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -29348,6 +29883,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -29381,6 +29917,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -29417,6 +29954,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -29987,6 +30525,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -30010,6 +30549,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -30019,7 +30559,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 8a239717f..ffecfbe05 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -4689,6 +4689,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -4746,6 +4747,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -4766,6 +4770,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -4920,6 +4925,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -5080,6 +5093,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5144,6 +5167,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5165,6 +5189,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -5503,6 +5528,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5575,6 +5615,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -5607,6 +5648,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -5642,6 +5684,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -6621,6 +6664,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6643,6 +6687,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6651,7 +6696,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -6675,6 +6720,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6734,6 +6780,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6754,6 +6803,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -6910,6 +6960,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -7070,6 +7128,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7138,6 +7206,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7163,6 +7232,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -7510,6 +7580,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7585,6 +7670,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7617,6 +7703,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -7654,6 +7741,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8269,6 +8357,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8291,6 +8380,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8299,7 +8389,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -8323,6 +8413,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8382,6 +8473,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8402,6 +8496,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8558,6 +8653,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8718,6 +8821,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8786,6 +8899,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8811,6 +8925,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -9158,6 +9273,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9233,6 +9363,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9265,6 +9396,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -9302,6 +9434,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9924,6 +10057,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -9946,6 +10080,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -9954,7 +10089,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -9977,6 +10112,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -10034,6 +10170,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10054,6 +10193,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -10207,6 +10347,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10366,6 +10514,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10430,6 +10588,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10450,6 +10609,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -10788,6 +10948,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10860,6 +11035,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -10892,6 +11068,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -10927,6 +11104,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11389,6 +11567,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11411,6 +11590,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11419,7 +11599,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -11442,6 +11622,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -11499,6 +11680,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -11519,6 +11703,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -11673,6 +11858,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -11832,6 +12025,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11896,6 +12099,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11916,6 +12120,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -12254,6 +12459,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12326,6 +12546,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -12358,6 +12579,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() validated = true } @@ -12393,6 +12615,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -12962,6 +13185,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -12984,6 +13208,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -12992,7 +13217,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index aae64719e..8b368841e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -5818,6 +5818,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5876,6 +5877,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5899,6 +5903,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6054,6 +6059,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -6223,6 +6236,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6296,6 +6319,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6318,6 +6342,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -6660,6 +6685,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6749,6 +6789,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6782,6 +6823,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -6818,6 +6860,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -7798,6 +7841,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7821,6 +7865,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7830,7 +7875,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -7853,6 +7898,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7912,6 +7958,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7935,6 +7984,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8090,6 +8140,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -8259,6 +8317,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8334,6 +8402,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8357,6 +8426,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -8701,6 +8771,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8790,6 +8875,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8823,6 +8909,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -8861,6 +8948,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -9567,6 +9655,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -9590,6 +9679,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -9599,7 +9689,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -9623,6 +9713,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -9683,6 +9774,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9706,6 +9800,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -9863,6 +9958,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -10032,6 +10135,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10109,6 +10222,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10135,6 +10249,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -10486,6 +10601,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10578,6 +10708,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -10611,6 +10742,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -10649,6 +10781,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -11265,6 +11398,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -11288,6 +11422,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -11297,7 +11432,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -11321,6 +11456,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -11381,6 +11517,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -11404,6 +11543,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -11561,6 +11701,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -11730,6 +11878,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11807,6 +11965,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11833,6 +11992,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -12184,6 +12344,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12276,6 +12451,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -12309,6 +12485,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -12347,6 +12524,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -12970,6 +13148,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12993,6 +13172,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13002,7 +13182,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -13025,6 +13205,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -13083,6 +13264,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -13106,6 +13290,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -13260,6 +13445,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -13428,6 +13621,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -13501,6 +13704,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -13522,6 +13726,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -13864,6 +14069,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13953,6 +14173,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13986,6 +14207,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -14022,6 +14244,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -14485,6 +14708,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14508,6 +14732,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -14517,7 +14742,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -14540,6 +14765,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -14598,6 +14824,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -14621,6 +14850,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -14776,6 +15006,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -14944,6 +15182,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -15017,6 +15265,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -15038,6 +15287,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -15380,6 +15630,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -15469,6 +15734,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -15502,6 +15768,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -15538,6 +15805,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -16108,6 +16376,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -16131,6 +16400,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -16140,7 +16410,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -19254,6 +19524,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -19312,6 +19583,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -19335,6 +19609,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -19490,6 +19765,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -19659,6 +19942,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -19732,6 +20025,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -19754,6 +20048,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -20096,6 +20391,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -20185,6 +20495,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -20218,6 +20529,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -20254,6 +20566,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -21234,6 +21547,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21257,6 +21571,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21266,7 +21581,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -21289,6 +21604,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21348,6 +21664,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -21371,6 +21690,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21526,6 +21846,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -21695,6 +22023,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -21770,6 +22108,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -21793,6 +22132,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -22137,6 +22477,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22226,6 +22581,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22259,6 +22615,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -22297,6 +22654,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -23003,6 +23361,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23026,6 +23385,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23035,7 +23395,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -23059,6 +23419,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23119,6 +23480,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23142,6 +23506,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23299,6 +23664,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -23468,6 +23841,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23545,6 +23928,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -23571,6 +23955,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -23922,6 +24307,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24014,6 +24414,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24047,6 +24448,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -24085,6 +24487,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -24701,6 +25104,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24724,6 +25128,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24733,7 +25138,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -24757,6 +25162,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24817,6 +25223,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24840,6 +25249,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -24997,6 +25407,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -25166,6 +25584,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25243,6 +25671,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25269,6 +25698,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -25620,6 +26050,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25712,6 +26157,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25745,6 +26191,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -25783,6 +26230,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -26406,6 +26854,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26429,6 +26878,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26438,7 +26888,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -26461,6 +26911,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26519,6 +26970,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26542,6 +26996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26696,6 +27151,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -26864,6 +27327,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26937,6 +27410,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -26958,6 +27432,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -27300,6 +27775,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27389,6 +27879,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27422,6 +27913,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -27458,6 +27950,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -27921,6 +28414,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -27944,6 +28438,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -27953,7 +28448,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -27976,6 +28471,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -28034,6 +28530,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -28057,6 +28556,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -28212,6 +28712,14 @@ private constructor( fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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 @@ -28380,6 +28888,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -28453,6 +28971,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -28474,6 +28993,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -28816,6 +29336,21 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -28905,6 +29440,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -28938,6 +29474,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration()?.validate() + licenseTypeId() metadata()?.validate() referenceId() validated = true @@ -28974,6 +29511,7 @@ private constructor( (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) @@ -29544,6 +30082,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -29567,6 +30106,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -29576,7 +30116,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index 2637f7854..f17400dae 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -162,7 +162,8 @@ interface LedgerServiceAsync { * 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. + * the cost basis with the number of credit units added. Additionally, Orb also enforces invoice + * generation when a non-zero `per_unit_cost_basis` value is provided. * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -274,7 +275,8 @@ interface LedgerServiceAsync { * 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. + * the cost basis with the number of credit units added. Additionally, Orb also enforces invoice + * generation when a non-zero `per_unit_cost_basis` value is provided. * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index d1b9051ad..0d74586bc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -159,7 +159,8 @@ interface LedgerService { * 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. + * the cost basis with the number of credit units added. Additionally, Orb also enforces invoice + * generation when a non-zero `per_unit_cost_basis` value is provided. * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -271,7 +272,8 @@ interface LedgerService { * 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. + * the cost basis with the number of credit units added. Additionally, Orb also enforces invoice + * generation when a non-zero `per_unit_cost_basis` value is provided. * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 49e22110c..5cde73367 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -62,6 +62,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -141,6 +142,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -201,6 +209,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -278,6 +287,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -346,6 +362,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -425,6 +442,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt index 4af9f1f77..6365133d4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt @@ -28,6 +28,7 @@ internal class AllocationTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() assertThat(allocation.allowsRollover()).isEqualTo(true) @@ -47,6 +48,7 @@ internal class AllocationTest { .addValue("string") .build() ) + assertThat(allocation.licenseTypeId()).isEqualTo("license_type_id") } @Test @@ -69,6 +71,7 @@ internal class AllocationTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() val roundtrippedAllocation = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 459c41e11..2aabdd88e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -63,6 +63,7 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -110,6 +111,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -184,6 +186,7 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -231,6 +234,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -310,6 +314,7 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -359,6 +364,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -433,6 +439,7 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -482,6 +489,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -550,6 +558,7 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -597,6 +606,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -675,6 +685,7 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -722,6 +733,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index 22acc6b4a..d573e52d0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -63,6 +63,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -110,6 +111,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -184,6 +186,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -231,6 +234,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -314,6 +318,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -363,6 +368,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -437,6 +443,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -486,6 +493,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -554,6 +562,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -601,6 +610,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -679,6 +689,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -726,6 +737,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index a013bd44b..5890c5be0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -303,6 +303,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -394,6 +395,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -779,6 +787,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -870,6 +879,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1256,6 +1272,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1339,6 +1356,13 @@ internal class ChangedSubscriptionResourcesTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1713,6 +1737,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1796,6 +1821,13 @@ internal class ChangedSubscriptionResourcesTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2196,6 +2228,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2287,6 +2320,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2672,6 +2712,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2763,6 +2804,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 390cc855b..2cf8cd2c2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -76,6 +76,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -167,6 +168,13 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +246,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class CustomerCostListByExternalIdResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +419,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -494,6 +511,13 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index c27926b62..ff5de40ee 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -76,6 +76,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -167,6 +168,13 @@ internal class CustomerCostListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +246,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class CustomerCostListResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +419,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -494,6 +511,13 @@ internal class CustomerCostListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 3248e833b..80254f600 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -690,6 +698,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -786,6 +795,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 7a4064066..830687f94 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +697,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -785,6 +794,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 02d6d0a49..e8d42a435 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -262,6 +262,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -367,6 +368,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -734,6 +742,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -839,6 +848,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1209,6 +1225,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1314,6 +1331,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index f4a670bc0..324a46f65 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +697,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -785,6 +794,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index d58df0af6..05634410d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -262,6 +262,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -367,6 +368,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -734,6 +742,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -839,6 +848,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1209,6 +1225,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1314,6 +1331,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 04143323e..4d9316dcf 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +697,7 @@ internal class CustomerCreditLedgerListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -785,6 +794,13 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index b5519405f..2b20fe226 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -240,6 +240,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -331,6 +332,13 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -659,6 +667,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -742,6 +751,13 @@ internal class IncrementLedgerEntryTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1079,6 +1095,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1170,6 +1187,13 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index c3b22d840..5b8dfe0d7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -186,6 +186,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -265,6 +266,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -556,6 +564,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -633,6 +642,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -928,6 +944,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1007,6 +1024,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index 4e23973a1..54595f0d5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -86,6 +86,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -160,6 +161,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -265,6 +273,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -339,6 +348,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -449,6 +465,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -523,6 +540,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index d29aa1314..69cd680d7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -205,6 +205,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -296,6 +297,13 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -586,6 +594,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -669,6 +678,13 @@ internal class InvoiceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -973,6 +989,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1064,6 +1081,13 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 3043b7df2..4a387af52 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -182,6 +182,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -261,6 +262,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -543,6 +551,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -620,6 +629,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -904,6 +920,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -983,6 +1000,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index ecbe2b472..44730c0ec 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -421,6 +421,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -500,6 +501,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -584,6 +592,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -663,6 +672,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1000,6 +1016,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1105,6 +1122,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1521,6 +1545,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1626,6 +1651,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2149,6 +2181,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2226,6 +2259,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2305,6 +2345,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2382,6 +2423,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -2704,6 +2752,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2800,6 +2849,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3193,6 +3249,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3289,6 +3346,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3811,6 +3875,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3890,6 +3955,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -3974,6 +4046,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4053,6 +4126,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -4390,6 +4470,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4495,6 +4576,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4911,6 +4999,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5016,6 +5105,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt index a03182267..90e7b1d2a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt @@ -31,6 +31,7 @@ internal class NewAllocationPriceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() @@ -54,6 +55,7 @@ internal class NewAllocationPriceTest { .build() ) assertThat(newAllocationPrice.itemId()).isEqualTo("item_id") + assertThat(newAllocationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newAllocationPrice.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") } @@ -80,6 +82,7 @@ internal class NewAllocationPriceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt index f5e6f0403..82fe0751b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -111,6 +112,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingBulkPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingBulkPrice.metadata()) .isEqualTo( NewFloatingBulkPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt index 1326341ce..ed0553ced 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt @@ -63,6 +63,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingBulkWithProrationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingBulkWithProrationPrice.metadata()) .isEqualTo( NewFloatingBulkWithProrationPrice.Metadata.builder() @@ -197,6 +199,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt index bc31d68ab..b9ecd6893 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt @@ -61,6 +61,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -131,6 +132,8 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingCumulativeGroupedBulkPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingCumulativeGroupedBulkPrice.metadata()) .isEqualTo( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() @@ -191,6 +194,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt index cebafb107..d7e643ddd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +118,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedAllocationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingGroupedAllocationPrice.metadata()) .isEqualTo( NewFloatingGroupedAllocationPrice.Metadata.builder() @@ -170,6 +172,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt index 5024114f4..418b617b1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,8 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedTieredPackagePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingGroupedTieredPackagePrice.metadata()) .isEqualTo( NewFloatingGroupedTieredPackagePrice.Metadata.builder() @@ -209,6 +212,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt index 2c5b7e5b4..e9ab5058a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedTieredPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingGroupedTieredPrice.metadata()) .isEqualTo( NewFloatingGroupedTieredPrice.Metadata.builder() @@ -198,6 +200,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt index 086f81e57..596dad03d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt @@ -76,6 +76,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -158,6 +159,8 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedWithMeteredMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingGroupedWithMeteredMinimumPrice.metadata()) .isEqualTo( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -233,6 +236,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt index c3483007b..e3bbccce7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt @@ -58,6 +58,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,8 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedWithProratedMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingGroupedWithProratedMinimumPrice.metadata()) .isEqualTo( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() @@ -181,6 +184,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt index c0acf01a6..850c8bcb7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -125,6 +126,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingMatrixPrice.metadata()) .isEqualTo( NewFloatingMatrixPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt index 52190e650..ffa92e692 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt @@ -60,6 +60,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -129,6 +130,8 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixWithAllocationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingMatrixWithAllocationPrice.metadata()) .isEqualTo( NewFloatingMatrixWithAllocationPrice.Metadata.builder() @@ -188,6 +191,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt index ab4dc60e7..ae44ff86c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt @@ -61,6 +61,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,8 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixWithDisplayNamePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingMatrixWithDisplayNamePrice.metadata()) .isEqualTo( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() @@ -190,6 +193,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt index bb504e15b..a5f1854f2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,8 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMaxGroupTieredPackagePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingMaxGroupTieredPackagePrice.metadata()) .isEqualTo( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() @@ -209,6 +212,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt index b093ed239..034c17aa3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -115,6 +116,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMinimumCompositePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingMinimumCompositePrice.metadata()) .isEqualTo( NewFloatingMinimumCompositePrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt index f19650a2a..fbc03b8c0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -107,6 +108,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingPackagePrice.metadata()) .isEqualTo( NewFloatingPackagePrice.Metadata.builder() @@ -156,6 +158,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt index 29e99f0e2..f9a07a696 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +118,8 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingPackageWithAllocationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingPackageWithAllocationPrice.metadata()) .isEqualTo( NewFloatingPackageWithAllocationPrice.Metadata.builder() @@ -170,6 +173,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt index b7c746752..b74377a10 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -187,6 +188,8 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingScalableMatrixWithTieredPricingPrice.metadata()) .isEqualTo( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -272,6 +275,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index a387a2126..810142c2d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt @@ -70,6 +70,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -152,6 +153,8 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingScalableMatrixWithUnitPricingPrice.metadata()) .isEqualTo( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -221,6 +224,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt index e40323719..1df1f31af 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt @@ -68,6 +68,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -145,6 +146,8 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingThresholdTotalAmountPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingThresholdTotalAmountPrice.metadata()) .isEqualTo( NewFloatingThresholdTotalAmountPrice.Metadata.builder() @@ -212,6 +215,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt index 9222c9858..7ccb75832 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingTieredPackagePrice.metadata()) .isEqualTo( NewFloatingTieredPackagePrice.Metadata.builder() @@ -198,6 +200,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt index 70db94c44..9a1ab99d8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt @@ -73,6 +73,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -152,6 +153,8 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPackageWithMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newFloatingTieredPackageWithMinimumPrice.metadata()) .isEqualTo( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() @@ -224,6 +227,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt index 0b1ad1505..13b9de0e9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -125,6 +126,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingTieredPrice.metadata()) .isEqualTo( NewFloatingTieredPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt index 4c1244951..cbca775c3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredWithMinimumPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingTieredWithMinimumPrice.metadata()) .isEqualTo( NewFloatingTieredWithMinimumPrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt index a2fce3448..5d0405604 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt @@ -58,6 +58,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredWithProrationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingTieredWithProrationPrice.metadata()) .isEqualTo( NewFloatingTieredWithProrationPrice.Metadata.builder() @@ -181,6 +183,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index a74d263b9..4b393c58e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -101,6 +102,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingUnitPrice.metadata()) .isEqualTo( NewFloatingUnitPrice.Metadata.builder() @@ -148,6 +150,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt index b27455cc1..0cff42ff1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitWithPercentPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingUnitWithPercentPrice.metadata()) .isEqualTo( NewFloatingUnitWithPercentPrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt index 5d92ac1a6..27ad08f15 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -113,6 +114,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitWithProrationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newFloatingUnitWithProrationPrice.metadata()) .isEqualTo( NewFloatingUnitWithProrationPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt index 0157cd364..f43f3be85 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -112,6 +113,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanBulkPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanBulkPrice.metadata()) .isEqualTo( NewPlanBulkPrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt index 2fcf10a24..8749b6963 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt @@ -63,6 +63,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanBulkWithProrationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanBulkWithProrationPrice.metadata()) .isEqualTo( NewPlanBulkWithProrationPrice.Metadata.builder() @@ -197,6 +199,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt index 36c501bb0..b83b02c05 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt @@ -61,6 +61,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -131,6 +132,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanCumulativeGroupedBulkPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanCumulativeGroupedBulkPrice.metadata()) .isEqualTo( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() @@ -192,6 +194,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt index 5e22b6837..23dda2d29 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedAllocationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanGroupedAllocationPrice.metadata()) .isEqualTo( NewPlanGroupedAllocationPrice.Metadata.builder() @@ -170,6 +172,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt index fe2768ed2..cc75af197 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedTieredPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanGroupedTieredPackagePrice.metadata()) .isEqualTo( NewPlanGroupedTieredPackagePrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt index b2cfcba91..6eaeb4525 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -136,6 +137,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedTieredPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanGroupedTieredPrice.metadata()) .isEqualTo( NewPlanGroupedTieredPrice.Metadata.builder() @@ -200,6 +202,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt index 8f45e3f76..084a8a518 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt @@ -73,6 +73,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -154,6 +155,8 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedWithMeteredMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newPlanGroupedWithMeteredMinimumPrice.metadata()) .isEqualTo( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -227,6 +230,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt index 9caace8da..5301ef9f5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt @@ -57,6 +57,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -123,6 +124,8 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedWithProratedMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newPlanGroupedWithProratedMinimumPrice.metadata()) .isEqualTo( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() @@ -180,6 +183,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt index 19ac3b71e..9011f5e3a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanMatrixPrice.metadata()) .isEqualTo( NewPlanMatrixPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt index dfbe75165..92fd18e48 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt @@ -60,6 +60,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixWithAllocationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanMatrixWithAllocationPrice.metadata()) .isEqualTo( NewPlanMatrixWithAllocationPrice.Metadata.builder() @@ -190,6 +192,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt index 97c177e28..a04403d12 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt @@ -60,6 +60,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixWithDisplayNamePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanMatrixWithDisplayNamePrice.metadata()) .isEqualTo( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() @@ -190,6 +192,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt index 908236f45..644680a0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMaxGroupTieredPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanMaxGroupTieredPackagePrice.metadata()) .isEqualTo( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt index c85b69117..3025c23bc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMinimumCompositePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanMinimumCompositePrice.metadata()) .isEqualTo( NewPlanMinimumCompositePrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt index bf2b79b77..c2b972df9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -106,6 +107,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanPackagePrice.metadata()) .isEqualTo( NewPlanPackagePrice.Metadata.builder() @@ -156,6 +158,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt index 98a49d888..f2c50a1b8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -118,6 +119,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanPackageWithAllocationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanPackageWithAllocationPrice.metadata()) .isEqualTo( NewPlanPackageWithAllocationPrice.Metadata.builder() @@ -172,6 +174,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt index 6316d5afd..98e7dc9b4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -183,6 +184,8 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newPlanScalableMatrixWithTieredPricingPrice.metadata()) .isEqualTo( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -270,6 +273,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index b6c1600b0..6d9b741e4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt @@ -69,6 +69,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newPlanScalableMatrixWithUnitPricingPrice.metadata()) .isEqualTo( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -218,6 +221,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt index b0652a089..77e980800 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt @@ -68,6 +68,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -144,6 +145,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanThresholdTotalAmountPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanThresholdTotalAmountPrice.metadata()) .isEqualTo( NewPlanThresholdTotalAmountPrice.Metadata.builder() @@ -212,6 +214,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt index 30bbe4959..43a2b9f17 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -136,6 +137,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanTieredPackagePrice.metadata()) .isEqualTo( NewPlanTieredPackagePrice.Metadata.builder() @@ -200,6 +202,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt index 73e9780e2..9aaf59293 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt @@ -70,6 +70,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPackageWithMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newPlanTieredPackageWithMinimumPrice.metadata()) .isEqualTo( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() @@ -218,6 +221,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt index df536eea4..7fe6af89c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanTieredPrice.metadata()) .isEqualTo( NewPlanTieredPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt index b3e9ee8ea..de2de6deb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredWithMinimumPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanTieredWithMinimumPrice.metadata()) .isEqualTo( NewPlanTieredWithMinimumPrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index 65af2ecd7..205ae54e8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -102,6 +103,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanUnitPrice.metadata()) .isEqualTo( NewPlanUnitPrice.Metadata.builder() @@ -150,6 +152,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt index 87ac558d8..24709bf41 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitWithPercentPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanUnitWithPercentPrice.metadata()) .isEqualTo( NewPlanUnitWithPercentPrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt index fe6f859e6..9b61bed0b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -112,6 +113,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitWithProrationPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newPlanUnitWithProrationPrice.metadata()) .isEqualTo( NewPlanUnitWithProrationPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt index 80ee67f14..d96a67abb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionBulkPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionBulkPrice.metadata()) .isEqualTo( NewSubscriptionBulkPrice.Metadata.builder() @@ -168,6 +170,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt index db304f963..f7196b66d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt @@ -65,6 +65,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,8 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionBulkWithProrationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionBulkWithProrationPrice.metadata()) .isEqualTo( NewSubscriptionBulkWithProrationPrice.Metadata.builder() @@ -203,6 +206,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt index 34dec871b..0db826568 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt @@ -63,6 +63,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,8 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionCumulativeGroupedBulkPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionCumulativeGroupedBulkPrice.metadata()) .isEqualTo( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() @@ -198,6 +201,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt index 0917f44d5..b1fb4ad49 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -118,6 +119,8 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedAllocationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionGroupedAllocationPrice.metadata()) .isEqualTo( NewSubscriptionGroupedAllocationPrice.Metadata.builder() @@ -172,6 +175,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt index ddf18d03a..2beb257e3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt @@ -69,6 +69,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -146,6 +147,8 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedTieredPackagePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionGroupedTieredPackagePrice.metadata()) .isEqualTo( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() @@ -215,6 +218,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt index c587b8e07..310bc3228 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedTieredPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionGroupedTieredPrice.metadata()) .isEqualTo( NewSubscriptionGroupedTieredPrice.Metadata.builder() @@ -202,6 +204,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt index ad2499640..baae9c600 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt @@ -77,6 +77,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -165,6 +166,8 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.metadata()) .isEqualTo( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -243,6 +246,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt index 08a681998..e9dd02cb6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt @@ -58,6 +58,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,8 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedWithProratedMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionGroupedWithProratedMinimumPrice.metadata()) .isEqualTo( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() @@ -189,6 +192,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt index 25d87020d..019b98394 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -126,6 +127,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionMatrixPrice.metadata()) .isEqualTo( NewSubscriptionMatrixPrice.Metadata.builder() @@ -185,6 +187,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt index 500e0edf8..dc14df864 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt @@ -62,6 +62,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -132,6 +133,8 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixWithAllocationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionMatrixWithAllocationPrice.metadata()) .isEqualTo( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() @@ -194,6 +197,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt index 22e5656f9..a0a6181eb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt @@ -63,6 +63,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,8 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixWithDisplayNamePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionMatrixWithDisplayNamePrice.metadata()) .isEqualTo( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() @@ -198,6 +201,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt index f5ed48d10..9e28ec3ba 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt @@ -71,6 +71,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMaxGroupTieredPackagePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionMaxGroupTieredPackagePrice.metadata()) .isEqualTo( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() @@ -220,6 +223,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt index 019aa7e49..3419451a1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,8 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMinimumCompositePrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionMinimumCompositePrice.metadata()) .isEqualTo( NewSubscriptionMinimumCompositePrice.Metadata.builder() @@ -169,6 +172,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt index 89db836da..ae3f5155e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -108,6 +109,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionPackagePrice.metadata()) .isEqualTo( NewSubscriptionPackagePrice.Metadata.builder() @@ -158,6 +160,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt index fd0a8c31a..4443bd7a9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt @@ -56,6 +56,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -120,6 +121,8 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionPackageWithAllocationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionPackageWithAllocationPrice.metadata()) .isEqualTo( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() @@ -177,6 +180,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt index d18079001..138edbc0e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -196,6 +197,8 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.metadata()) .isEqualTo( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -283,6 +286,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index 88521ee0c..8c6a769fa 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt @@ -70,6 +70,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -160,6 +161,8 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.metadata()) .isEqualTo( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -231,6 +234,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt index 420a96ce9..4d3a015d9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt @@ -70,6 +70,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionThresholdTotalAmountPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionThresholdTotalAmountPrice.metadata()) .isEqualTo( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() @@ -218,6 +221,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt index ea2ffaee5..90f165614 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPackagePrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionTieredPackagePrice.metadata()) .isEqualTo( NewSubscriptionTieredPackagePrice.Metadata.builder() @@ -202,6 +204,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt index 5c439c752..d92809589 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt @@ -76,6 +76,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -159,6 +160,8 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPackageWithMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionTieredPackageWithMinimumPrice.metadata()) .isEqualTo( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() @@ -236,6 +239,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt index 497d65f80..028e43c87 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -126,6 +127,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionTieredPrice.metadata()) .isEqualTo( NewSubscriptionTieredPrice.Metadata.builder() @@ -185,6 +187,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt index 90bdb5722..b83b84b8a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt @@ -69,6 +69,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -146,6 +147,8 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredWithMinimumPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionTieredWithMinimumPrice.metadata()) .isEqualTo( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() @@ -215,6 +218,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index 7a25fc48f..82b1407c7 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -104,6 +105,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionUnitPrice.metadata()) .isEqualTo( NewSubscriptionUnitPrice.Metadata.builder() @@ -152,6 +154,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt index 7b99e00b2..48d70f59b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitWithPercentPrice.licenseTypeId()).isEqualTo("license_type_id") assertThat(newSubscriptionUnitWithPercentPrice.metadata()) .isEqualTo( NewSubscriptionUnitWithPercentPrice.Metadata.builder() @@ -169,6 +171,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt index 9922c5992..fe57f67c3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,8 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitWithProrationPrice.licenseTypeId()) + .isEqualTo("license_type_id") assertThat(newSubscriptionUnitWithProrationPrice.metadata()) .isEqualTo( NewSubscriptionUnitWithProrationPrice.Metadata.builder() @@ -166,6 +169,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 43dbfd2a7..16697ddb8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -56,6 +56,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -130,6 +131,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -181,6 +189,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -255,6 +264,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -310,6 +326,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -384,6 +401,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index 236bd88d4..e36d40f19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -35,6 +35,7 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -82,6 +83,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -168,6 +170,7 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -217,6 +220,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -301,6 +305,7 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -348,6 +353,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index f88092a24..749c61a5f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -210,6 +210,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -289,6 +290,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -502,6 +510,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -579,6 +588,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -802,6 +818,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -881,6 +898,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index b62525d63..395168c41 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -197,6 +197,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -271,6 +272,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -485,6 +493,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -559,6 +568,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -768,6 +784,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -842,6 +859,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 9598f0122..0b1bb8780 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -88,6 +88,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -162,6 +163,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .version(0L) @@ -247,6 +255,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -405,6 +421,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -479,6 +496,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .version(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt index 4f4e9b97c..21470db42 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt @@ -49,6 +49,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -103,6 +104,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -156,6 +158,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index 34d0427ab..fd2af83c0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -64,6 +64,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -203,6 +205,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index dd34c6175..ea83e3915 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -77,6 +77,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -161,6 +162,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -243,6 +245,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 9beca844c..da55a6f0f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -70,6 +70,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -144,6 +145,13 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -211,6 +219,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -285,6 +294,13 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -353,6 +369,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -427,6 +444,13 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index adcd2fae7..65d4d7789 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -56,6 +56,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -130,6 +131,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .paginationMetadata( @@ -180,6 +188,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -254,6 +263,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -307,6 +323,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -381,6 +398,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .paginationMetadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 8d45fe801..e0bc9668e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -58,6 +58,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -130,6 +131,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnit(unit) @@ -212,6 +220,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -286,6 +295,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -338,6 +354,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -421,6 +438,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Tiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTiered(tiered) @@ -503,6 +527,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -586,6 +611,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Tiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -645,6 +677,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -716,6 +749,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Bulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulk(bulk) @@ -808,6 +848,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -879,6 +920,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Bulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -953,6 +1001,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1024,6 +1073,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithFilters.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulkWithFilters(bulkWithFilters) @@ -1128,6 +1184,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1199,6 +1256,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithFilters.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1251,6 +1315,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1325,6 +1390,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Package.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPackage(package_) @@ -1407,6 +1479,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1484,6 +1557,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Package.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1536,6 +1616,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1619,6 +1700,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Matrix.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrix(matrix) @@ -1701,6 +1789,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1784,6 +1873,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Matrix.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1836,6 +1932,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1926,6 +2023,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ThresholdTotalAmount.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) @@ -2010,6 +2114,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2102,6 +2207,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ThresholdTotalAmount.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2154,6 +2266,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2242,6 +2355,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredPackage(tieredPackage) @@ -2324,6 +2444,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2412,6 +2533,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2464,6 +2592,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2555,6 +2684,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredWithMinimum(tieredWithMinimum) @@ -2639,6 +2775,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2730,6 +2867,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2782,6 +2926,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2870,6 +3015,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedTiered(groupedTiered) @@ -2952,6 +3104,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3040,6 +3193,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3094,6 +3254,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3186,6 +3347,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackageWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) @@ -3273,6 +3441,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3365,6 +3534,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackageWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3419,6 +3595,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3497,6 +3674,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.PackageWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPackageWithAllocation(packageWithAllocation) @@ -3581,6 +3765,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3659,6 +3844,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.PackageWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3711,6 +3903,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3788,6 +3981,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithPercent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnitWithPercent(unitWithPercent) @@ -3870,6 +4070,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3947,6 +4148,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithPercent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3999,6 +4207,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4083,6 +4292,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrixWithAllocation(matrixWithAllocation) @@ -4167,6 +4383,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4251,6 +4468,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4303,6 +4527,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4384,6 +4609,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredWithProration(tieredWithProration) @@ -4468,6 +4700,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4549,6 +4782,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4601,6 +4841,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4677,6 +4918,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnitWithProration(unitWithProration) @@ -4761,6 +5009,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4837,6 +5086,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4889,6 +5145,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4967,6 +5224,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedAllocation(groupedAllocation) @@ -5051,6 +5315,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5129,6 +5394,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5197,6 +5469,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5268,6 +5541,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulkWithProration(bulkWithProration) @@ -5368,6 +5648,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5439,6 +5720,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5493,6 +5781,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5571,6 +5860,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithProratedMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) @@ -5658,6 +5954,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5736,6 +6033,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithProratedMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5790,6 +6094,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5885,6 +6190,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMeteredMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) @@ -5972,6 +6284,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6067,6 +6380,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMeteredMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6123,6 +6443,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6202,6 +6523,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMinMaxThresholds.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) @@ -6290,6 +6618,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6370,6 +6699,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMinMaxThresholds.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6424,6 +6760,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6508,6 +6845,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithDisplayName.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) @@ -6592,6 +6936,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6676,6 +7021,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithDisplayName.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6728,6 +7080,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6817,6 +7170,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedTieredPackage(groupedTieredPackage) @@ -6901,6 +7261,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6990,6 +7351,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7044,6 +7412,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7133,6 +7502,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MaxGroupTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) @@ -7217,6 +7593,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7308,6 +7685,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MaxGroupTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7365,6 +7749,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7454,6 +7839,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithUnitPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) @@ -7542,6 +7934,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7632,6 +8025,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithUnitPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7690,6 +8090,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7796,6 +8197,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithTieredPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) @@ -7885,6 +8293,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7991,6 +8400,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithTieredPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8045,6 +8461,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedBulkConfig( @@ -8129,6 +8546,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedBulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) @@ -8213,6 +8637,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedBulkConfig( @@ -8298,6 +8723,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedBulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8354,6 +8786,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedAllocationConfig( @@ -8433,6 +8866,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation) @@ -8521,6 +8961,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedAllocationConfig( @@ -8601,6 +9042,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8653,6 +9101,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8730,6 +9179,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MinimumComposite.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMinimumComposite(minimumComposite) @@ -8812,6 +9268,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8889,6 +9346,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MinimumComposite.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8941,6 +9405,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9013,6 +9478,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Percent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPercent(percent) @@ -9095,6 +9567,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9167,6 +9640,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Percent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -9219,6 +9699,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9297,6 +9778,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.EventOutput.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofEventOutput(eventOutput) @@ -9379,6 +9867,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9457,6 +9946,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.EventOutput.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index e7bc57a31..ae9c217a2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -461,6 +461,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -552,6 +553,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +658,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -741,6 +750,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1132,6 +1148,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1255,6 +1272,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1770,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1869,6 +1894,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2438,6 +2470,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2521,6 +2554,13 @@ internal class SubscriptionChangeApplyResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2650,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2693,6 +2734,13 @@ internal class SubscriptionChangeApplyResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -3056,6 +3104,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3172,6 +3221,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3681,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3741,6 +3798,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4329,6 +4393,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4420,6 +4485,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4590,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4609,6 +4682,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -5000,6 +5080,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5123,6 +5204,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5702,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5737,6 +5826,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index b80e094fe..0a12d86ad 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -461,6 +461,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -552,6 +553,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +658,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -741,6 +750,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1132,6 +1148,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1255,6 +1272,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1770,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1869,6 +1894,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2438,6 +2470,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2521,6 +2554,13 @@ internal class SubscriptionChangeCancelResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2650,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2693,6 +2734,13 @@ internal class SubscriptionChangeCancelResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -3056,6 +3104,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3172,6 +3221,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3681,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3741,6 +3798,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4329,6 +4393,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4420,6 +4485,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4590,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4609,6 +4682,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -5000,6 +5080,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5123,6 +5204,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5702,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5737,6 +5826,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 75089ebbb..8f64e7cc4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -461,6 +461,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -552,6 +553,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +658,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -741,6 +750,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1132,6 +1148,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1255,6 +1272,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1770,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1869,6 +1894,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2438,6 +2470,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2521,6 +2554,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2650,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2693,6 +2734,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -3056,6 +3104,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3172,6 +3221,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3681,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3741,6 +3798,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4329,6 +4393,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4420,6 +4485,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4590,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4609,6 +4682,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -5000,6 +5080,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5123,6 +5204,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5702,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5737,6 +5826,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index 79ba16c55..ad36172d3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -64,6 +64,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -123,6 +124,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -227,6 +229,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -285,6 +288,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -358,6 +362,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -419,6 +424,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -523,6 +529,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -583,6 +590,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -655,6 +663,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -714,6 +723,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -824,6 +834,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -882,6 +893,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 0ae21fa3e..b10c24d7e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -76,6 +76,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -167,6 +168,13 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +246,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class SubscriptionFetchCostsResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +419,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -494,6 +511,13 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 9ddb51e3d..3a9a8c965 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -36,6 +36,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -95,6 +96,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -203,6 +205,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -265,6 +268,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -361,6 +365,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -420,6 +425,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 83dd5bb9b..987719acc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -66,6 +66,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -125,6 +126,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -220,6 +222,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -278,6 +281,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -365,6 +369,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -426,6 +431,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -521,6 +527,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -581,6 +588,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -654,6 +662,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -713,6 +722,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -810,6 +820,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -868,6 +879,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 29688caf6..738294d81 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -421,6 +421,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -500,6 +501,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -584,6 +592,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -663,6 +672,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1093,6 +1109,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1170,6 +1187,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1249,6 +1273,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1326,6 +1351,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1762,6 +1794,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1841,6 +1874,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1925,6 +1965,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2004,6 +2045,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 93ca1b208..bcbbda776 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -457,6 +457,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -548,6 +549,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -646,6 +654,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -737,6 +746,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1187,6 +1203,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1270,6 +1287,13 @@ internal class SubscriptionsTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1359,6 +1383,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1442,6 +1467,13 @@ internal class SubscriptionsTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1915,6 +1947,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2006,6 +2039,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2104,6 +2144,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2195,6 +2236,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 32d02018b..9c1c15f50 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -88,6 +88,7 @@ internal class BetaServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -141,6 +142,7 @@ internal class BetaServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,6 +219,7 @@ internal class BetaServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -270,6 +273,7 @@ internal class BetaServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index e64d85947..b84a4af74 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -57,6 +57,7 @@ internal class PlanServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -110,6 +111,7 @@ internal class PlanServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index a0a6e8614..3f9434b37 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -77,6 +77,7 @@ internal class PriceServiceAsyncTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -225,6 +226,7 @@ internal class PriceServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -326,6 +328,7 @@ internal class PriceServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 933aced72..fc57ff8e2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -103,6 +103,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -168,6 +169,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -274,6 +276,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -338,6 +341,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -540,6 +544,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -606,6 +611,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -774,6 +780,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -839,6 +846,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -936,6 +944,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1000,6 +1009,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 9f444c1fb..c3514f8f5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -88,6 +88,7 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -141,6 +142,7 @@ internal class ExternalPlanIdServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,6 +219,7 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -270,6 +273,7 @@ internal class ExternalPlanIdServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 7f538b370..4cd03a79c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -88,6 +88,7 @@ internal class BetaServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -141,6 +142,7 @@ internal class BetaServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,6 +219,7 @@ internal class BetaServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -270,6 +273,7 @@ internal class BetaServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 62e6a8a4e..f8787dff0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -57,6 +57,7 @@ internal class PlanServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -110,6 +111,7 @@ internal class PlanServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index de3c5a9ae..210e40c9b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -77,6 +77,7 @@ internal class PriceServiceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -225,6 +226,7 @@ internal class PriceServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -326,6 +328,7 @@ internal class PriceServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 457bb6fcd..26f820f7b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -103,6 +103,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -168,6 +169,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -274,6 +276,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -338,6 +341,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -540,6 +544,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -606,6 +611,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -774,6 +780,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -839,6 +846,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -936,6 +944,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -1000,6 +1009,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index 961704179..5ec00a8bc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -88,6 +88,7 @@ internal class ExternalPlanIdServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -141,6 +142,7 @@ internal class ExternalPlanIdServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,6 +219,7 @@ internal class ExternalPlanIdServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -270,6 +273,7 @@ internal class ExternalPlanIdServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) From 27696395e8c530e533347fef4e024f8a7c938776 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 04:22:54 +0000 Subject: [PATCH 05/52] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index a77b80771..3a5a4c8eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6aa83a816c15600a3d6d378d7804a345505c76726059c19369db4e7766a71cbd.yml -openapi_spec_hash: f283d730e5320f9595c3c0a5902f5cbb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-90b631890d57a96df99cc973fedfb48e6278b025dcb6262519eb064044d47efe.yml +openapi_spec_hash: b17b00ef11d479516d6f1e5a323aef28 config_hash: bcf82bddb691f6be773ac6cae8c03b9a From 4e9e830d982ed89d6e3f3a08e8dd952dedf44676 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:20:35 +0000 Subject: [PATCH 06/52] chore(internal): codegen related update --- .../api/models/InvoiceListSummaryParams.kt | 24 ++++++------------- .../models/InvoiceListSummaryParamsTest.kt | 6 ++--- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt index 4247b39e4..39f70ec71 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt @@ -8,7 +8,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.LocalDate import java.time.OffsetDateTime @@ -51,7 +50,7 @@ private constructor( private val invoiceDateLte: OffsetDateTime?, private val isRecurring: Boolean?, private val limit: Long?, - private val status: List?, + private val status: Status?, private val subscriptionId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -101,7 +100,7 @@ private constructor( /** The number of items to fetch. Defaults to 20. */ fun limit(): Long? = limit - fun status(): List? = status + fun status(): Status? = status fun subscriptionId(): String? = subscriptionId @@ -141,7 +140,7 @@ private constructor( private var invoiceDateLte: OffsetDateTime? = null private var isRecurring: Boolean? = null private var limit: Long? = null - private var status: MutableList? = null + private var status: Status? = null private var subscriptionId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -164,7 +163,7 @@ private constructor( invoiceDateLte = invoiceListSummaryParams.invoiceDateLte isRecurring = invoiceListSummaryParams.isRecurring limit = invoiceListSummaryParams.limit - status = invoiceListSummaryParams.status?.toMutableList() + status = invoiceListSummaryParams.status subscriptionId = invoiceListSummaryParams.subscriptionId additionalHeaders = invoiceListSummaryParams.additionalHeaders.toBuilder() additionalQueryParams = invoiceListSummaryParams.additionalQueryParams.toBuilder() @@ -238,16 +237,7 @@ private constructor( */ fun limit(limit: Long) = limit(limit as Long?) - fun status(status: List?) = apply { this.status = status?.toMutableList() } - - /** - * Adds a single [Status] to [Builder.status]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStatus(status: Status) = apply { - this.status = (this.status ?: mutableListOf()).apply { add(status) } - } + fun status(status: Status?) = apply { this.status = status } fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } @@ -373,7 +363,7 @@ private constructor( invoiceDateLte, isRecurring, limit, - status?.toImmutable(), + status, subscriptionId, additionalHeaders.build(), additionalQueryParams.build(), @@ -410,7 +400,7 @@ private constructor( } isRecurring?.let { put("is_recurring", it.toString()) } limit?.let { put("limit", it.toString()) } - status?.forEach { put("status[]", it.toString()) } + status?.let { put("status", it.toString()) } subscriptionId?.let { put("subscription_id", it) } putAll(additionalQueryParams) } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListSummaryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListSummaryParamsTest.kt index 3c43002f9..39891c11d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListSummaryParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListSummaryParamsTest.kt @@ -30,7 +30,7 @@ internal class InvoiceListSummaryParamsTest { .invoiceDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .isRecurring(true) .limit(1L) - .addStatus(InvoiceListSummaryParams.Status.DRAFT) + .status(InvoiceListSummaryParams.Status.DRAFT) .subscriptionId("subscription_id") .build() } @@ -56,7 +56,7 @@ internal class InvoiceListSummaryParamsTest { .invoiceDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .isRecurring(true) .limit(1L) - .addStatus(InvoiceListSummaryParams.Status.DRAFT) + .status(InvoiceListSummaryParams.Status.DRAFT) .subscriptionId("subscription_id") .build() @@ -82,7 +82,7 @@ internal class InvoiceListSummaryParamsTest { .put("invoice_date[lte]", "2019-12-27T18:11:19.117Z") .put("is_recurring", "true") .put("limit", "1") - .put("status[]", "draft") + .put("status", "draft") .put("subscription_id", "subscription_id") .build() ) From 808e0728d3848bdcbd4e3ace9e4cf7e3e7fe9852 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:22:59 +0000 Subject: [PATCH 07/52] feat(api): api update --- .stats.yml | 4 +- .../api/models/CreditBlockRetrieveResponse.kt | 149 +++++++++++++++++- .../CustomerCreditListByExternalIdParams.kt | 69 +++++++- .../CustomerCreditListByExternalIdResponse.kt | 149 +++++++++++++++++- .../api/models/CustomerCreditListParams.kt | 69 +++++++- .../api/models/CustomerCreditListResponse.kt | 149 +++++++++++++++++- .../async/customers/CreditServiceAsync.kt | 10 ++ .../blocking/customers/CreditService.kt | 10 ++ .../models/CreditBlockRetrieveResponseTest.kt | 17 ++ ...rCreditListByExternalIdPageResponseTest.kt | 16 ++ ...ustomerCreditListByExternalIdParamsTest.kt | 13 ++ ...tomerCreditListByExternalIdResponseTest.kt | 17 ++ .../CustomerCreditListPageResponseTest.kt | 16 ++ .../models/CustomerCreditListParamsTest.kt | 13 ++ .../models/CustomerCreditListResponseTest.kt | 17 ++ 15 files changed, 711 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3a5a4c8eb..67224ec77 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-90b631890d57a96df99cc973fedfb48e6278b025dcb6262519eb064044d47efe.yml -openapi_spec_hash: b17b00ef11d479516d6f1e5a323aef28 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c92fb451e13f157b3735f188acc8d57aa3adfbaac1683645e1ba4f432dd7a4f8.yml +openapi_spec_hash: dbcd87ecfbd3976eb3b99ec6f9fbc606 config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt index c073cb9ec..dce37466a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt @@ -29,6 +29,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -50,6 +51,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -61,6 +63,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -103,6 +106,16 @@ private constructor( fun maximumInitialBalance(): Double? = maximumInitialBalance.getNullable("maximum_initial_balance") + /** + * 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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -164,6 +177,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -206,6 +226,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -222,6 +243,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -233,6 +255,7 @@ private constructor( expiryDate = creditBlockRetrieveResponse.expiryDate filters = creditBlockRetrieveResponse.filters.map { it.toMutableList() } maximumInitialBalance = creditBlockRetrieveResponse.maximumInitialBalance + metadata = creditBlockRetrieveResponse.metadata perUnitCostBasis = creditBlockRetrieveResponse.perUnitCostBasis status = creditBlockRetrieveResponse.status additionalProperties = creditBlockRetrieveResponse.additionalProperties.toMutableMap() @@ -332,6 +355,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * 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`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -388,6 +427,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -402,6 +442,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -421,6 +462,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -446,6 +488,7 @@ private constructor( (if (expiryDate.asKnown() == null) 0 else 1) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) @@ -977,6 +1020,108 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1113,6 +1258,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1126,6 +1272,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1135,5 +1282,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockRetrieveResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CreditBlockRetrieveResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt index eef95cfd7..50c8186f4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt @@ -5,6 +5,8 @@ package com.withorb.api.models import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects /** @@ -15,12 +17,21 @@ import java.util.Objects * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ class CustomerCreditListByExternalIdParams private constructor( private val externalCustomerId: String?, private val currency: String?, private val cursor: String?, + private val effectiveDateGt: OffsetDateTime?, + private val effectiveDateGte: OffsetDateTime?, + private val effectiveDateLt: OffsetDateTime?, + private val effectiveDateLte: OffsetDateTime?, private val includeAllBlocks: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, @@ -38,6 +49,14 @@ private constructor( */ fun cursor(): String? = cursor + fun effectiveDateGt(): OffsetDateTime? = effectiveDateGt + + fun effectiveDateGte(): OffsetDateTime? = effectiveDateGte + + fun effectiveDateLt(): OffsetDateTime? = effectiveDateLt + + fun effectiveDateLte(): OffsetDateTime? = effectiveDateLte + /** * If set to True, all expired and depleted blocks, as well as active block will be returned. */ @@ -71,6 +90,10 @@ private constructor( private var externalCustomerId: String? = null private var currency: String? = null private var cursor: String? = null + private var effectiveDateGt: OffsetDateTime? = null + private var effectiveDateGte: OffsetDateTime? = null + private var effectiveDateLt: OffsetDateTime? = null + private var effectiveDateLte: OffsetDateTime? = null private var includeAllBlocks: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -82,6 +105,10 @@ private constructor( externalCustomerId = customerCreditListByExternalIdParams.externalCustomerId currency = customerCreditListByExternalIdParams.currency cursor = customerCreditListByExternalIdParams.cursor + effectiveDateGt = customerCreditListByExternalIdParams.effectiveDateGt + effectiveDateGte = customerCreditListByExternalIdParams.effectiveDateGte + effectiveDateLt = customerCreditListByExternalIdParams.effectiveDateLt + effectiveDateLte = customerCreditListByExternalIdParams.effectiveDateLte includeAllBlocks = customerCreditListByExternalIdParams.includeAllBlocks limit = customerCreditListByExternalIdParams.limit additionalHeaders = customerCreditListByExternalIdParams.additionalHeaders.toBuilder() @@ -102,6 +129,22 @@ private constructor( */ fun cursor(cursor: String?) = apply { this.cursor = cursor } + fun effectiveDateGt(effectiveDateGt: OffsetDateTime?) = apply { + this.effectiveDateGt = effectiveDateGt + } + + fun effectiveDateGte(effectiveDateGte: OffsetDateTime?) = apply { + this.effectiveDateGte = effectiveDateGte + } + + fun effectiveDateLt(effectiveDateLt: OffsetDateTime?) = apply { + this.effectiveDateLt = effectiveDateLt + } + + fun effectiveDateLte(effectiveDateLte: OffsetDateTime?) = apply { + this.effectiveDateLte = effectiveDateLte + } + /** * If set to True, all expired and depleted blocks, as well as active block will be * returned. @@ -236,6 +279,10 @@ private constructor( externalCustomerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders.build(), @@ -256,6 +303,18 @@ private constructor( .apply { currency?.let { put("currency", it) } cursor?.let { put("cursor", it) } + effectiveDateGt?.let { + put("effective_date[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateGte?.let { + put("effective_date[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLt?.let { + put("effective_date[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLte?.let { + put("effective_date[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } includeAllBlocks?.let { put("include_all_blocks", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) @@ -271,6 +330,10 @@ private constructor( externalCustomerId == other.externalCustomerId && currency == other.currency && cursor == other.cursor && + effectiveDateGt == other.effectiveDateGt && + effectiveDateGte == other.effectiveDateGte && + effectiveDateLt == other.effectiveDateLt && + effectiveDateLte == other.effectiveDateLte && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && @@ -282,6 +345,10 @@ private constructor( externalCustomerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders, @@ -289,5 +356,5 @@ private constructor( ) override fun toString() = - "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, effectiveDateGt=$effectiveDateGt, effectiveDateGte=$effectiveDateGte, effectiveDateLt=$effectiveDateLt, effectiveDateLte=$effectiveDateLte, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index 0ff7dc002..f2bb4ed5b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -28,6 +28,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -49,6 +50,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -60,6 +62,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -102,6 +105,16 @@ private constructor( fun maximumInitialBalance(): Double? = maximumInitialBalance.getNullable("maximum_initial_balance") + /** + * 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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -163,6 +176,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -206,6 +226,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -222,6 +243,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -235,6 +257,7 @@ private constructor( expiryDate = customerCreditListByExternalIdResponse.expiryDate filters = customerCreditListByExternalIdResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListByExternalIdResponse.maximumInitialBalance + metadata = customerCreditListByExternalIdResponse.metadata perUnitCostBasis = customerCreditListByExternalIdResponse.perUnitCostBasis status = customerCreditListByExternalIdResponse.status additionalProperties = @@ -335,6 +358,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * 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`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -391,6 +430,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -405,6 +445,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -424,6 +465,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -449,6 +491,7 @@ private constructor( (if (expiryDate.asKnown() == null) 0 else 1) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) @@ -957,6 +1000,108 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1093,6 +1238,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1106,6 +1252,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1115,5 +1262,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt index 0920dd6f5..d784d7e58 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt @@ -5,6 +5,8 @@ package com.withorb.api.models import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects /** @@ -15,12 +17,21 @@ import java.util.Objects * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ class CustomerCreditListParams private constructor( private val customerId: String?, private val currency: String?, private val cursor: String?, + private val effectiveDateGt: OffsetDateTime?, + private val effectiveDateGte: OffsetDateTime?, + private val effectiveDateLt: OffsetDateTime?, + private val effectiveDateLte: OffsetDateTime?, private val includeAllBlocks: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, @@ -38,6 +49,14 @@ private constructor( */ fun cursor(): String? = cursor + fun effectiveDateGt(): OffsetDateTime? = effectiveDateGt + + fun effectiveDateGte(): OffsetDateTime? = effectiveDateGte + + fun effectiveDateLt(): OffsetDateTime? = effectiveDateLt + + fun effectiveDateLte(): OffsetDateTime? = effectiveDateLte + /** * If set to True, all expired and depleted blocks, as well as active block will be returned. */ @@ -68,6 +87,10 @@ private constructor( private var customerId: String? = null private var currency: String? = null private var cursor: String? = null + private var effectiveDateGt: OffsetDateTime? = null + private var effectiveDateGte: OffsetDateTime? = null + private var effectiveDateLt: OffsetDateTime? = null + private var effectiveDateLte: OffsetDateTime? = null private var includeAllBlocks: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -77,6 +100,10 @@ private constructor( customerId = customerCreditListParams.customerId currency = customerCreditListParams.currency cursor = customerCreditListParams.cursor + effectiveDateGt = customerCreditListParams.effectiveDateGt + effectiveDateGte = customerCreditListParams.effectiveDateGte + effectiveDateLt = customerCreditListParams.effectiveDateLt + effectiveDateLte = customerCreditListParams.effectiveDateLte includeAllBlocks = customerCreditListParams.includeAllBlocks limit = customerCreditListParams.limit additionalHeaders = customerCreditListParams.additionalHeaders.toBuilder() @@ -94,6 +121,22 @@ private constructor( */ fun cursor(cursor: String?) = apply { this.cursor = cursor } + fun effectiveDateGt(effectiveDateGt: OffsetDateTime?) = apply { + this.effectiveDateGt = effectiveDateGt + } + + fun effectiveDateGte(effectiveDateGte: OffsetDateTime?) = apply { + this.effectiveDateGte = effectiveDateGte + } + + fun effectiveDateLt(effectiveDateLt: OffsetDateTime?) = apply { + this.effectiveDateLt = effectiveDateLt + } + + fun effectiveDateLte(effectiveDateLte: OffsetDateTime?) = apply { + this.effectiveDateLte = effectiveDateLte + } + /** * If set to True, all expired and depleted blocks, as well as active block will be * returned. @@ -228,6 +271,10 @@ private constructor( customerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders.build(), @@ -248,6 +295,18 @@ private constructor( .apply { currency?.let { put("currency", it) } cursor?.let { put("cursor", it) } + effectiveDateGt?.let { + put("effective_date[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateGte?.let { + put("effective_date[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLt?.let { + put("effective_date[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLte?.let { + put("effective_date[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } includeAllBlocks?.let { put("include_all_blocks", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) @@ -263,6 +322,10 @@ private constructor( customerId == other.customerId && currency == other.currency && cursor == other.cursor && + effectiveDateGt == other.effectiveDateGt && + effectiveDateGte == other.effectiveDateGte && + effectiveDateLt == other.effectiveDateLt && + effectiveDateLte == other.effectiveDateLte && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && @@ -274,6 +337,10 @@ private constructor( customerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders, @@ -281,5 +348,5 @@ private constructor( ) override fun toString() = - "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, effectiveDateGt=$effectiveDateGt, effectiveDateGte=$effectiveDateGte, effectiveDateLt=$effectiveDateLt, effectiveDateLte=$effectiveDateLte, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 3f0ddaa3b..4a460c26e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -28,6 +28,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -49,6 +50,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -60,6 +62,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -102,6 +105,16 @@ private constructor( fun maximumInitialBalance(): Double? = maximumInitialBalance.getNullable("maximum_initial_balance") + /** + * 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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -163,6 +176,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -205,6 +225,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -221,6 +242,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -232,6 +254,7 @@ private constructor( expiryDate = customerCreditListResponse.expiryDate filters = customerCreditListResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListResponse.maximumInitialBalance + metadata = customerCreditListResponse.metadata perUnitCostBasis = customerCreditListResponse.perUnitCostBasis status = customerCreditListResponse.status additionalProperties = customerCreditListResponse.additionalProperties.toMutableMap() @@ -331,6 +354,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * 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`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -387,6 +426,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -401,6 +441,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -420,6 +461,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -445,6 +487,7 @@ private constructor( (if (expiryDate.asKnown() == null) 0 else 1) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + (status.asKnown()?.validity() ?: 0) @@ -953,6 +996,108 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1089,6 +1234,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1102,6 +1248,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1111,5 +1258,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt index f6b71bcef..27f96b76a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt @@ -39,6 +39,11 @@ interface CreditServiceAsync { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ suspend fun list( customerId: String, @@ -68,6 +73,11 @@ interface CreditServiceAsync { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ suspend fun listByExternalId( externalCustomerId: String, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt index 8a934b8e9..98d912884 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt @@ -39,6 +39,11 @@ interface CreditService { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun list( customerId: String, @@ -65,6 +70,11 @@ interface CreditService { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun listByExternalId( externalCustomerId: String, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt index db71eaedb..f690b5058 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CreditBlockRetrieveResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CreditBlockRetrieveResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CreditBlockRetrieveResponseTest { .build() ) assertThat(creditBlockRetrieveResponse.maximumInitialBalance()).isEqualTo(0.0) + assertThat(creditBlockRetrieveResponse.metadata()) + .isEqualTo( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(creditBlockRetrieveResponse.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") assertThat(creditBlockRetrieveResponse.status()) .isEqualTo(CreditBlockRetrieveResponse.Status.ACTIVE) @@ -67,6 +79,11 @@ internal class CreditBlockRetrieveResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CreditBlockRetrieveResponse.Status.ACTIVE) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt index add48b6d5..b52a00271 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -30,6 +31,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -56,6 +62,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -85,6 +96,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt index c02f88add..a6ee7c823 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,6 +15,10 @@ internal class CustomerCreditListByExternalIdParamsTest { .externalCustomerId("external_customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -38,6 +43,10 @@ internal class CustomerCreditListByExternalIdParamsTest { .externalCustomerId("external_customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -49,6 +58,10 @@ internal class CustomerCreditListByExternalIdParamsTest { QueryParams.builder() .put("currency", "currency") .put("cursor", "cursor") + .put("effective_date[gt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[gte]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lte]", "2019-12-27T18:11:19.117Z") .put("include_all_blocks", "true") .put("limit", "1") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt index dc3c6207c..f848687b2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) assertThat(customerCreditListByExternalIdResponse.maximumInitialBalance()).isEqualTo(0.0) + assertThat(customerCreditListByExternalIdResponse.metadata()) + .isEqualTo( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(customerCreditListByExternalIdResponse.perUnitCostBasis()) .isEqualTo("per_unit_cost_basis") assertThat(customerCreditListByExternalIdResponse.status()) @@ -68,6 +80,11 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt index 86c3c5fce..6164150d2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -28,6 +29,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -52,6 +58,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -79,6 +90,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt index 35a23e2e9..63dceb213 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,6 +15,10 @@ internal class CustomerCreditListParamsTest { .customerId("customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -35,6 +40,10 @@ internal class CustomerCreditListParamsTest { .customerId("customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -46,6 +55,10 @@ internal class CustomerCreditListParamsTest { QueryParams.builder() .put("currency", "currency") .put("cursor", "cursor") + .put("effective_date[gt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[gte]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lte]", "2019-12-27T18:11:19.117Z") .put("include_all_blocks", "true") .put("limit", "1") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt index 25792b1ee..ad265f62e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CustomerCreditListResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CustomerCreditListResponseTest { .build() ) assertThat(customerCreditListResponse.maximumInitialBalance()).isEqualTo(0.0) + assertThat(customerCreditListResponse.metadata()) + .isEqualTo( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(customerCreditListResponse.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") assertThat(customerCreditListResponse.status()) .isEqualTo(CustomerCreditListResponse.Status.ACTIVE) @@ -67,6 +79,11 @@ internal class CustomerCreditListResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() From d93464c286e31f707862d8a961c5f454351022e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 19:05:18 +0000 Subject: [PATCH 08/52] feat(api): manual updates added new endpoints --- .stats.yml | 4 +- .../com/withorb/api/client/OrbClient.kt | 10 + .../com/withorb/api/client/OrbClientAsync.kt | 10 + .../withorb/api/client/OrbClientAsyncImpl.kt | 28 + .../com/withorb/api/client/OrbClientImpl.kt | 26 + .../models/CreditBlockListInvoicesParams.kt | 203 + .../models/CreditBlockListInvoicesResponse.kt | 1980 ++++++++ .../api/models/InvoiceIssueSummaryParams.kt | 436 ++ .../api/models/InvoiceIssueSummaryResponse.kt | 4464 +++++++++++++++++ .../withorb/api/models/LicenseCreateParams.kt | 744 +++ .../api/models/LicenseCreateResponse.kt | 545 ++ .../api/models/LicenseDeactivateParams.kt | 419 ++ .../api/models/LicenseDeactivateResponse.kt | 545 ++ .../LicenseExternalLicenseGetUsageParams.kt | 344 ++ .../LicenseExternalLicenseGetUsageResponse.kt | 933 ++++ .../com/withorb/api/models/LicenseListPage.kt | 132 + .../api/models/LicenseListPageAsync.kt | 132 + .../api/models/LicenseListPageResponse.kt | 234 + .../withorb/api/models/LicenseListParams.kt | 407 ++ .../withorb/api/models/LicenseListResponse.kt | 545 ++ .../LicenseRetrieveByExternalIdParams.kt | 243 + .../LicenseRetrieveByExternalIdResponse.kt | 549 ++ .../api/models/LicenseRetrieveParams.kt | 187 + .../api/models/LicenseRetrieveResponse.kt | 545 ++ .../api/models/LicenseTypeCreateParams.kt | 501 ++ .../api/models/LicenseTypeCreateResponse.kt | 257 + .../withorb/api/models/LicenseTypeListPage.kt | 132 + .../api/models/LicenseTypeListPageAsync.kt | 132 + .../api/models/LicenseTypeListPageResponse.kt | 236 + .../api/models/LicenseTypeListParams.kt | 221 + .../api/models/LicenseTypeListResponse.kt | 257 + .../api/models/LicenseTypeRetrieveParams.kt | 195 + .../api/models/LicenseTypeRetrieveResponse.kt | 257 + .../models/LicenseUsageGetAllUsageParams.kt | 323 ++ .../models/LicenseUsageGetAllUsageResponse.kt | 932 ++++ .../api/models/LicenseUsageGetUsageParams.kt | 299 ++ .../models/LicenseUsageGetUsageResponse.kt | 929 ++++ .../services/async/CreditBlockServiceAsync.kt | 64 + .../async/CreditBlockServiceAsyncImpl.kt | 39 + .../api/services/async/InvoiceServiceAsync.kt | 59 + .../services/async/InvoiceServiceAsyncImpl.kt | 40 + .../api/services/async/LicenseServiceAsync.kt | 237 + .../services/async/LicenseServiceAsyncImpl.kt | 271 + .../services/async/LicenseTypeServiceAsync.kt | 152 + .../async/LicenseTypeServiceAsyncImpl.kt | 165 + .../licenses/ExternalLicenseServiceAsync.kt | 82 + .../ExternalLicenseServiceAsyncImpl.kt | 85 + .../async/licenses/UsageServiceAsync.kt | 112 + .../async/licenses/UsageServiceAsyncImpl.kt | 119 + .../services/blocking/CreditBlockService.kt | 64 + .../blocking/CreditBlockServiceImpl.kt | 39 + .../api/services/blocking/InvoiceService.kt | 59 + .../services/blocking/InvoiceServiceImpl.kt | 40 + .../api/services/blocking/LicenseService.kt | 228 + .../services/blocking/LicenseServiceImpl.kt | 267 + .../services/blocking/LicenseTypeService.kt | 149 + .../blocking/LicenseTypeServiceImpl.kt | 165 + .../licenses/ExternalLicenseService.kt | 82 + .../licenses/ExternalLicenseServiceImpl.kt | 83 + .../blocking/licenses/UsageService.kt | 107 + .../blocking/licenses/UsageServiceImpl.kt | 117 + .../CreditBlockListInvoicesParamsTest.kt | 23 + .../CreditBlockListInvoicesResponseTest.kt | 157 + .../models/InvoiceIssueSummaryParamsTest.kt | 40 + .../models/InvoiceIssueSummaryResponseTest.kt | 401 ++ .../api/models/LicenseCreateParamsTest.kt | 57 + .../api/models/LicenseCreateResponseTest.kt | 59 + .../api/models/LicenseDeactivateParamsTest.kt | 47 + .../models/LicenseDeactivateResponseTest.kt | 60 + ...icenseExternalLicenseGetUsageParamsTest.kt | 89 + ...enseExternalLicenseGetUsageResponseTest.kt | 94 + .../api/models/LicenseListPageResponseTest.kt | 78 + .../api/models/LicenseListParamsTest.kt | 59 + .../api/models/LicenseListResponseTest.kt | 59 + .../LicenseRetrieveByExternalIdParamsTest.kt | 53 + ...LicenseRetrieveByExternalIdResponseTest.kt | 63 + .../api/models/LicenseRetrieveParamsTest.kt | 23 + .../api/models/LicenseRetrieveResponseTest.kt | 60 + .../api/models/LicenseTypeCreateParamsTest.kt | 25 + .../models/LicenseTypeCreateResponseTest.kt | 44 + .../models/LicenseTypeListPageResponseTest.kt | 65 + .../api/models/LicenseTypeListParamsTest.kt | 34 + .../api/models/LicenseTypeListResponseTest.kt | 44 + .../models/LicenseTypeRetrieveParamsTest.kt | 23 + .../models/LicenseTypeRetrieveResponseTest.kt | 44 + .../LicenseUsageGetAllUsageParamsTest.kt | 72 + .../LicenseUsageGetAllUsageResponseTest.kt | 94 + .../models/LicenseUsageGetUsageParamsTest.kt | 67 + .../LicenseUsageGetUsageResponseTest.kt | 93 + .../async/CreditBlockServiceAsyncTest.kt | 14 + .../services/async/InvoiceServiceAsyncTest.kt | 21 + .../services/async/LicenseServiceAsyncTest.kt | 112 + .../async/LicenseTypeServiceAsyncTest.kt | 58 + .../ExternalLicenseServiceAsyncTest.kt | 40 + .../async/licenses/UsageServiceAsyncTest.kt | 64 + .../blocking/CreditBlockServiceTest.kt | 14 + .../services/blocking/InvoiceServiceTest.kt | 21 + .../services/blocking/LicenseServiceTest.kt | 112 + .../blocking/LicenseTypeServiceTest.kt | 58 + .../licenses/ExternalLicenseServiceTest.kt | 40 + .../blocking/licenses/UsageServiceTest.kt | 64 + .../api/proguard/ProGuardCompatibilityTest.kt | 2 + 102 files changed, 23806 insertions(+), 2 deletions(-) create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt create mode 100644 orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 67224ec77..c80eee48c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 126 +configured_endpoints: 139 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c92fb451e13f157b3735f188acc8d57aa3adfbaac1683645e1ba4f432dd7a4f8.yml openapi_spec_hash: dbcd87ecfbd3976eb3b99ec6f9fbc606 -config_hash: bcf82bddb691f6be773ac6cae8c03b9a +config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt index 710e3b486..ba2270776 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt @@ -14,6 +14,8 @@ import com.withorb.api.services.blocking.EventService import com.withorb.api.services.blocking.InvoiceLineItemService import com.withorb.api.services.blocking.InvoiceService import com.withorb.api.services.blocking.ItemService +import com.withorb.api.services.blocking.LicenseService +import com.withorb.api.services.blocking.LicenseTypeService import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.PlanService import com.withorb.api.services.blocking.PriceService @@ -94,6 +96,10 @@ interface OrbClient { fun creditBlocks(): CreditBlockService + fun licenseTypes(): LicenseTypeService + + fun licenses(): LicenseService + /** * Closes this client, relinquishing any underlying resources. * @@ -150,5 +156,9 @@ interface OrbClient { fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse fun creditBlocks(): CreditBlockService.WithRawResponse + + fun licenseTypes(): LicenseTypeService.WithRawResponse + + fun licenses(): LicenseService.WithRawResponse } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt index f46caadca..c28cafb22 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt @@ -14,6 +14,8 @@ import com.withorb.api.services.async.EventServiceAsync import com.withorb.api.services.async.InvoiceLineItemServiceAsync import com.withorb.api.services.async.InvoiceServiceAsync import com.withorb.api.services.async.ItemServiceAsync +import com.withorb.api.services.async.LicenseServiceAsync +import com.withorb.api.services.async.LicenseTypeServiceAsync import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.PlanServiceAsync import com.withorb.api.services.async.PriceServiceAsync @@ -91,6 +93,10 @@ interface OrbClientAsync { fun creditBlocks(): CreditBlockServiceAsync + fun licenseTypes(): LicenseTypeServiceAsync + + fun licenses(): LicenseServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -147,5 +153,9 @@ interface OrbClientAsync { fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse + + fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse + + fun licenses(): LicenseServiceAsync.WithRawResponse } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index 5ff626dd4..c1f5a400c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.async.InvoiceServiceAsync import com.withorb.api.services.async.InvoiceServiceAsyncImpl import com.withorb.api.services.async.ItemServiceAsync import com.withorb.api.services.async.ItemServiceAsyncImpl +import com.withorb.api.services.async.LicenseServiceAsync +import com.withorb.api.services.async.LicenseServiceAsyncImpl +import com.withorb.api.services.async.LicenseTypeServiceAsync +import com.withorb.api.services.async.LicenseTypeServiceAsyncImpl import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.MetricServiceAsyncImpl import com.withorb.api.services.async.PlanServiceAsync @@ -118,6 +122,14 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs CreditBlockServiceAsyncImpl(clientOptionsWithUserAgent) } + private val licenseTypes: LicenseTypeServiceAsync by lazy { + LicenseTypeServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val licenses: LicenseServiceAsync by lazy { + LicenseServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): OrbClient = sync override fun withRawResponse(): OrbClientAsync.WithRawResponse = withRawResponse @@ -160,6 +172,10 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun creditBlocks(): CreditBlockServiceAsync = creditBlocks + override fun licenseTypes(): LicenseTypeServiceAsync = licenseTypes + + override fun licenses(): LicenseServiceAsync = licenses + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -234,6 +250,14 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs CreditBlockServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val licenseTypes: LicenseTypeServiceAsync.WithRawResponse by lazy { + LicenseTypeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val licenses: LicenseServiceAsync.WithRawResponse by lazy { + LicenseServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: (ClientOptions.Builder) -> Unit ): OrbClientAsync.WithRawResponse = @@ -277,5 +301,9 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs subscriptionChanges override fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse = creditBlocks + + override fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse = licenseTypes + + override fun licenses(): LicenseServiceAsync.WithRawResponse = licenses } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index 21420041e..14eaba40a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.blocking.InvoiceService import com.withorb.api.services.blocking.InvoiceServiceImpl import com.withorb.api.services.blocking.ItemService import com.withorb.api.services.blocking.ItemServiceImpl +import com.withorb.api.services.blocking.LicenseService +import com.withorb.api.services.blocking.LicenseServiceImpl +import com.withorb.api.services.blocking.LicenseTypeService +import com.withorb.api.services.blocking.LicenseTypeServiceImpl import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.MetricServiceImpl import com.withorb.api.services.blocking.PlanService @@ -110,6 +114,12 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { CreditBlockServiceImpl(clientOptionsWithUserAgent) } + private val licenseTypes: LicenseTypeService by lazy { + LicenseTypeServiceImpl(clientOptionsWithUserAgent) + } + + private val licenses: LicenseService by lazy { LicenseServiceImpl(clientOptionsWithUserAgent) } + override fun async(): OrbClientAsync = async override fun withRawResponse(): OrbClient.WithRawResponse = withRawResponse @@ -153,6 +163,10 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun creditBlocks(): CreditBlockService = creditBlocks + override fun licenseTypes(): LicenseTypeService = licenseTypes + + override fun licenses(): LicenseService = licenses + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -226,6 +240,14 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { CreditBlockServiceImpl.WithRawResponseImpl(clientOptions) } + private val licenseTypes: LicenseTypeService.WithRawResponse by lazy { + LicenseTypeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val licenses: LicenseService.WithRawResponse by lazy { + LicenseServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: (ClientOptions.Builder) -> Unit ): OrbClient.WithRawResponse = @@ -266,5 +288,9 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { subscriptionChanges override fun creditBlocks(): CreditBlockService.WithRawResponse = creditBlocks + + override fun licenseTypes(): LicenseTypeService.WithRawResponse = licenseTypes + + override fun licenses(): LicenseService.WithRawResponse = licenses } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt new file mode 100644 index 000000000..ce7bf6d35 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects + +/** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added or allocated from a + * subscription), this endpoint returns the invoices that were created to charge the customer for + * the credit block. For credit blocks with payment schedules spanning multiple periods (e.g., + * monthly payments over 12 months), multiple invoices will be returned. + * + * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices + * list is returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future releases. + * Please contact support before building production integrations against this endpoint.** + */ +class CreditBlockListInvoicesParams +private constructor( + private val blockId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun blockId(): String? = blockId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): CreditBlockListInvoicesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CreditBlockListInvoicesParams]. + */ + fun builder() = Builder() + } + + /** A builder for [CreditBlockListInvoicesParams]. */ + class Builder internal constructor() { + + private var blockId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(creditBlockListInvoicesParams: CreditBlockListInvoicesParams) = apply { + blockId = creditBlockListInvoicesParams.blockId + additionalHeaders = creditBlockListInvoicesParams.additionalHeaders.toBuilder() + additionalQueryParams = creditBlockListInvoicesParams.additionalQueryParams.toBuilder() + } + + fun blockId(blockId: String?) = apply { this.blockId = blockId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreditBlockListInvoicesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditBlockListInvoicesParams = + CreditBlockListInvoicesParams( + blockId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> blockId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditBlockListInvoicesParams && + blockId == other.blockId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(blockId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CreditBlockListInvoicesParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt new file mode 100644 index 000000000..be49082fc --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt @@ -0,0 +1,1980 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class CreditBlockListInvoicesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val block: JsonField, + private val invoices: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("block") @ExcludeMissing block: JsonField = JsonMissing.of(), + @JsonProperty("invoices") + @ExcludeMissing + invoices: JsonField> = JsonMissing.of(), + ) : this(block, invoices, mutableMapOf()) + + /** + * The Credit Block resource models prepaid credits within Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun block(): Block = block.getRequired("block") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoices(): List = invoices.getRequired("invoices") + + /** + * Returns the raw JSON value of [block]. + * + * Unlike [block], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("block") @ExcludeMissing fun _block(): JsonField = block + + /** + * Returns the raw JSON value of [invoices]. + * + * Unlike [invoices], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoices") @ExcludeMissing fun _invoices(): JsonField> = invoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CreditBlockListInvoicesResponse]. + * + * The following fields are required: + * ```kotlin + * .block() + * .invoices() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CreditBlockListInvoicesResponse]. */ + class Builder internal constructor() { + + private var block: JsonField? = null + private var invoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(creditBlockListInvoicesResponse: CreditBlockListInvoicesResponse) = + apply { + block = creditBlockListInvoicesResponse.block + invoices = creditBlockListInvoicesResponse.invoices.map { it.toMutableList() } + additionalProperties = + creditBlockListInvoicesResponse.additionalProperties.toMutableMap() + } + + /** The Credit Block resource models prepaid credits within Orb. */ + fun block(block: Block) = block(JsonField.of(block)) + + /** + * Sets [Builder.block] to an arbitrary JSON value. + * + * You should usually call [Builder.block] with a well-typed [Block] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun block(block: JsonField) = apply { this.block = block } + + fun invoices(invoices: List) = invoices(JsonField.of(invoices)) + + /** + * Sets [Builder.invoices] to an arbitrary JSON value. + * + * You should usually call [Builder.invoices] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoices(invoices: JsonField>) = apply { + this.invoices = invoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [invoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInvoice(invoice: Invoice) = apply { + invoices = + (invoices ?: JsonField.of(mutableListOf())).also { + checkKnown("invoices", it).add(invoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditBlockListInvoicesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .block() + * .invoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse( + checkRequired("block", block), + checkRequired("invoices", invoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditBlockListInvoicesResponse = apply { + if (validated) { + return@apply + } + + block().validate() + invoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (block.asKnown()?.validity() ?: 0) + + (invoices.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** The Credit Block resource models prepaid credits within Orb. */ + class Block + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val balance: JsonField, + private val effectiveDate: JsonField, + private val expiryDate: JsonField, + private val filters: JsonField>, + private val maximumInitialBalance: JsonField, + private val metadata: JsonField, + private val perUnitCostBasis: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this( + id, + balance, + effectiveDate, + expiryDate, + filters, + maximumInitialBalance, + metadata, + perUnitCostBasis, + status, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun balance(): Double = balance.getRequired("balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun effectiveDate(): OffsetDateTime? = effectiveDate.getNullable("effective_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryDate(): OffsetDateTime? = expiryDate.getNullable("expiry_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maximumInitialBalance(): Double? = + maximumInitialBalance.getNullable("maximum_initial_balance") + + /** + * 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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun perUnitCostBasis(): String? = perUnitCostBasis.getNullable("per_unit_cost_basis") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [balance]. + * + * Unlike [balance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [expiryDate]. + * + * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [maximumInitialBalance]. + * + * Unlike [maximumInitialBalance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + fun _maximumInitialBalance(): JsonField = maximumInitialBalance + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [perUnitCostBasis]. + * + * Unlike [perUnitCostBasis], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Block]. + * + * The following fields are required: + * ```kotlin + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .filters() + * .maximumInitialBalance() + * .metadata() + * .perUnitCostBasis() + * .status() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Block]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var balance: JsonField? = null + private var effectiveDate: JsonField? = null + private var expiryDate: JsonField? = null + private var filters: JsonField>? = null + private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(block: Block) = apply { + id = block.id + balance = block.balance + effectiveDate = block.effectiveDate + expiryDate = block.expiryDate + filters = block.filters.map { it.toMutableList() } + maximumInitialBalance = block.maximumInitialBalance + metadata = block.metadata + perUnitCostBasis = block.perUnitCostBasis + status = block.status + additionalProperties = block.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun balance(balance: Double) = balance(JsonField.of(balance)) + + /** + * Sets [Builder.balance] to an arbitrary JSON value. + * + * You should usually call [Builder.balance] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun balance(balance: JsonField) = apply { this.balance = balance } + + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + /** + * Sets [Builder.expiryDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun maximumInitialBalance(maximumInitialBalance: Double?) = + maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) + + /** + * Alias for [Builder.maximumInitialBalance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maximumInitialBalance(maximumInitialBalance: Double) = + maximumInitialBalance(maximumInitialBalance as Double?) + + /** + * Sets [Builder.maximumInitialBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumInitialBalance] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { + this.maximumInitialBalance = maximumInitialBalance + } + + /** + * 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`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + /** + * Sets [Builder.perUnitCostBasis] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitCostBasis] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Block]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .filters() + * .maximumInitialBalance() + * .metadata() + * .perUnitCostBasis() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Block = + Block( + checkRequired("id", id), + checkRequired("balance", balance), + checkRequired("effectiveDate", effectiveDate), + checkRequired("expiryDate", expiryDate), + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), + checkRequired("perUnitCostBasis", perUnitCostBasis), + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Block = apply { + if (validated) { + return@apply + } + + id() + balance() + effectiveDate() + expiryDate() + filters().forEach { it.validate() } + maximumInitialBalance() + metadata().validate() + perUnitCostBasis() + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (balance.asKnown() == null) 0 else 1) + + (if (effectiveDate.asKnown() == null) 0 else 1) + + (if (expiryDate.asKnown() == null) 0 else 1) + + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maximumInitialBalance.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (field.asKnown()?.validity() ?: 0) + + (operator.asKnown()?.validity() ?: 0) + + (values.asKnown()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val PRICE_ID = of("price_id") + + val ITEM_ID = of("item_id") + + val PRICE_TYPE = of("price_type") + + val CURRENCY = of("currency") + + val PRICING_UNIT_ID = of("pricing_unit_id") + + fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCLUDES = of("includes") + + val EXCLUDES = of("excludes") + + fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val PENDING_PAYMENT = of("pending_payment") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PENDING_PAYMENT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PENDING_PAYMENT, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PENDING_PAYMENT -> Value.PENDING_PAYMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PENDING_PAYMENT -> Known.PENDING_PAYMENT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Block && + id == other.id && + balance == other.balance && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + filters == other.filters && + maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && + perUnitCostBasis == other.perUnitCostBasis && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + balance, + effectiveDate, + expiryDate, + filters, + maximumInitialBalance, + metadata, + perUnitCostBasis, + status, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Block{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val customer: JsonField, + private val invoiceNumber: JsonField, + private val status: JsonField, + private val subscription: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + ) : this(id, customer, invoiceNumber, status, subscription, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun subscription(): SubscriptionMinified? = subscription.getNullable("subscription") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```kotlin + * .id() + * .customer() + * .invoiceNumber() + * .status() + * .subscription() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var customer: JsonField? = null + private var invoiceNumber: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(invoice: Invoice) = apply { + id = invoice.id + customer = invoice.customer + invoiceNumber = invoice.invoiceNumber + status = invoice.status + subscription = invoice.subscription + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed + * [SubscriptionMinified] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .customer() + * .invoiceNumber() + * .status() + * .subscription() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("id", id), + checkRequired("customer", customer), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("status", status), + checkRequired("subscription", subscription), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + id() + customer().validate() + invoiceNumber() + status().validate() + subscription()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (customer.asKnown()?.validity() ?: 0) + + (if (invoiceNumber.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + (subscription.asKnown()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ISSUED = of("issued") + + val PAID = of("paid") + + val SYNCED = of("synced") + + val VOID = of("void") + + val DRAFT = of("draft") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + id == other.id && + customer == other.customer && + invoiceNumber == other.invoiceNumber && + status == other.status && + subscription == other.subscription && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, customer, invoiceNumber, status, subscription, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{id=$id, customer=$customer, invoiceNumber=$invoiceNumber, status=$status, subscription=$subscription, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditBlockListInvoicesResponse && + block == other.block && + invoices == other.invoices && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(block, invoices, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditBlockListInvoicesResponse{block=$block, invoices=$invoices, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt new file mode 100644 index 000000000..acddf859f --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt @@ -0,0 +1,436 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * 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). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice summary + * without any line item details. + */ +class InvoiceIssueSummaryParams +private constructor( + private val invoiceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun invoiceId(): String? = invoiceId + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun synchronous(): Boolean? = body.synchronous() + + /** + * Returns the raw JSON value of [synchronous]. + * + * Unlike [synchronous], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _synchronous(): JsonField = body._synchronous() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): InvoiceIssueSummaryParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [InvoiceIssueSummaryParams]. + */ + fun builder() = Builder() + } + + /** A builder for [InvoiceIssueSummaryParams]. */ + class Builder internal constructor() { + + private var invoiceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(invoiceIssueSummaryParams: InvoiceIssueSummaryParams) = apply { + invoiceId = invoiceIssueSummaryParams.invoiceId + body = invoiceIssueSummaryParams.body.toBuilder() + additionalHeaders = invoiceIssueSummaryParams.additionalHeaders.toBuilder() + additionalQueryParams = invoiceIssueSummaryParams.additionalQueryParams.toBuilder() + } + + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [synchronous] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have 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(synchronous: Boolean) = apply { body.synchronous(synchronous) } + + /** + * Sets [Builder.synchronous] to an arbitrary JSON value. + * + * You should usually call [Builder.synchronous] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun synchronous(synchronous: JsonField) = apply { body.synchronous(synchronous) } + + 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) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InvoiceIssueSummaryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvoiceIssueSummaryParams = + InvoiceIssueSummaryParams( + invoiceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> invoiceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val synchronous: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("synchronous") + @ExcludeMissing + synchronous: JsonField = JsonMissing.of() + ) : this(synchronous, mutableMapOf()) + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun synchronous(): Boolean? = synchronous.getNullable("synchronous") + + /** + * Returns the raw JSON value of [synchronous]. + * + * Unlike [synchronous], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("synchronous") + @ExcludeMissing + fun _synchronous(): JsonField = synchronous + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var synchronous: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(body: Body) = apply { + synchronous = body.synchronous + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be + * issued asynchronously. The synchronous option is only available for invoices that + * have 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(synchronous: Boolean) = synchronous(JsonField.of(synchronous)) + + /** + * Sets [Builder.synchronous] to an arbitrary JSON value. + * + * You should usually call [Builder.synchronous] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun synchronous(synchronous: JsonField) = apply { + this.synchronous = synchronous + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(synchronous, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + synchronous() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (synchronous.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + synchronous == other.synchronous && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(synchronous, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{synchronous=$synchronous, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceIssueSummaryParams && + invoiceId == other.invoiceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InvoiceIssueSummaryParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt new file mode 100644 index 000000000..94c605903 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt @@ -0,0 +1,4464 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +/** #InvoiceApiResourceWithoutLineItems */ +class InvoiceIssueSummaryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val amountDue: JsonField, + private val autoCollection: JsonField, + private val billingAddress: JsonField
, + private val createdAt: JsonField, + private val creditNotes: JsonField>, + private val currency: JsonField, + private val customer: JsonField, + private val customerBalanceTransactions: JsonField>, + private val customerTaxId: JsonField, + private val dueDate: JsonField, + private val eligibleToIssueAt: JsonField, + private val hostedInvoiceUrl: JsonField, + private val invoiceDate: JsonField, + private val invoiceNumber: JsonField, + private val invoicePdf: JsonField, + private val invoiceSource: JsonField, + private val issueFailedAt: JsonField, + private val issuedAt: JsonField, + private val memo: JsonField, + private val metadata: JsonField, + private val paidAt: JsonField, + private val paymentAttempts: JsonField>, + private val paymentFailedAt: JsonField, + private val paymentStartedAt: JsonField, + private val scheduledIssueAt: JsonField, + private val shippingAddress: JsonField
, + private val status: JsonField, + private val subscription: JsonField, + private val syncFailedAt: JsonField, + private val total: JsonField, + private val voidedAt: JsonField, + private val willAutoIssue: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount_due") @ExcludeMissing amountDue: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + billingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_notes") + @ExcludeMissing + creditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + customerBalanceTransactions: JsonField> = JsonMissing.of(), + @JsonProperty("customer_tax_id") + @ExcludeMissing + customerTaxId: JsonField = JsonMissing.of(), + @JsonProperty("due_date") + @ExcludeMissing + dueDate: JsonField = JsonMissing.of(), + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + eligibleToIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + hostedInvoiceUrl: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("invoice_pdf") + @ExcludeMissing + invoicePdf: JsonField = JsonMissing.of(), + @JsonProperty("invoice_source") + @ExcludeMissing + invoiceSource: JsonField = JsonMissing.of(), + @JsonProperty("issue_failed_at") + @ExcludeMissing + issueFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("issued_at") + @ExcludeMissing + issuedAt: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("paid_at") + @ExcludeMissing + paidAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_attempts") + @ExcludeMissing + paymentAttempts: JsonField> = JsonMissing.of(), + @JsonProperty("payment_failed_at") + @ExcludeMissing + paymentFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_started_at") + @ExcludeMissing + paymentStartedAt: JsonField = JsonMissing.of(), + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + scheduledIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("sync_failed_at") + @ExcludeMissing + syncFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + @JsonProperty("will_auto_issue") + @ExcludeMissing + willAutoIssue: JsonField = JsonMissing.of(), + ) : this( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + memo, + metadata, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun amountDue(): String = amountDue.getRequired("amount_due") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun autoCollection(): AutoCollection = autoCollection.getRequired("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingAddress(): Address? = billingAddress.getNullable("billing_address") + + /** + * The creation time of the resource in Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * A list of credit notes associated with the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditNotes(): List = creditNotes.getRequired("credit_notes") + + /** + * An ISO 4217 currency string or `credits` + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerBalanceTransactions(): List = + customerBalanceTransactions.getRequired("customer_balance_transactions") + + /** + * 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 | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |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 | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |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) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |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 | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`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 |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |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 | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT 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 | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT 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 | + * |Poland |`pl_nip` |Polish Tax ID 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 | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |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 | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun customerTaxId(): CustomerTaxId? = customerTaxId.getNullable("customer_tax_id") + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet finalized. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dueDate(): OffsetDateTime? = dueDate.getNullable("due_date") + + /** + * 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun eligibleToIssueAt(): OffsetDateTime? = eligibleToIssueAt.getNullable("eligible_to_issue_at") + + /** + * 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun hostedInvoiceUrl(): String? = hostedInvoiceUrl.getNullable("hosted_invoice_url") + + /** + * The scheduled date of the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceDate(): OffsetDateTime = invoiceDate.getRequired("invoice_date") + + /** + * 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * The link to download the PDF representation of the `Invoice`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoicePdf(): String? = invoicePdf.getNullable("invoice_pdf") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceSource(): InvoiceSource = invoiceSource.getRequired("invoice_source") + + /** + * 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.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun issueFailedAt(): OffsetDateTime? = issueFailedAt.getNullable("issue_failed_at") + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even if it + * is now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun issuedAt(): OffsetDateTime? = issuedAt.getNullable("issued_at") + + /** + * Free-form text which is available on the invoice PDF and the Orb invoice portal. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun memo(): String? = memo.getNullable("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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paidAt(): OffsetDateTime? = paidAt.getNullable("paid_at") + + /** + * A list of payment attempts associated with the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paymentAttempts(): List = paymentAttempts.getRequired("payment_attempts") + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most recent + * attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentFailedAt(): OffsetDateTime? = paymentFailedAt.getNullable("payment_failed_at") + + /** + * 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentStartedAt(): OffsetDateTime? = paymentStartedAt.getNullable("payment_started_at") + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be + * issued. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun scheduledIssueAt(): OffsetDateTime? = scheduledIssueAt.getNullable("scheduled_issue_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun shippingAddress(): Address? = shippingAddress.getNullable("shipping_address") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun subscription(): SubscriptionMinified? = subscription.getNullable("subscription") + + /** + * 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun syncFailedAt(): OffsetDateTime? = syncFailedAt.getNullable("sync_failed_at") + + /** + * The total after any minimums and discounts have been applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): String = total.getRequired("total") + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun voidedAt(): OffsetDateTime? = voidedAt.getNullable("voided_at") + + /** + * This is true if the invoice will be automatically issued in the future, and false otherwise. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amountDue]. + * + * Unlike [amountDue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingAddress]. + * + * Unlike [billingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField
= billingAddress + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNotes]. + * + * Unlike [creditNotes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [customerBalanceTransactions]. + * + * Unlike [customerBalanceTransactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions + + /** + * Returns the raw JSON value of [customerTaxId]. + * + * Unlike [customerTaxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + + /** + * Returns the raw JSON value of [eligibleToIssueAt]. + * + * Unlike [eligibleToIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + fun _eligibleToIssueAt(): JsonField = eligibleToIssueAt + + /** + * Returns the raw JSON value of [hostedInvoiceUrl]. + * + * Unlike [hostedInvoiceUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl + + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [invoicePdf]. + * + * Unlike [invoicePdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf(): JsonField = invoicePdf + + /** + * Returns the raw JSON value of [invoiceSource]. + * + * Unlike [invoiceSource], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = invoiceSource + + /** + * Returns the raw JSON value of [issueFailedAt]. + * + * Unlike [issueFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = issueFailedAt + + /** + * Returns the raw JSON value of [issuedAt]. + * + * Unlike [issuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt(): JsonField = issuedAt + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [paidAt]. + * + * Unlike [paidAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt + + /** + * Returns the raw JSON value of [paymentAttempts]. + * + * Unlike [paymentAttempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts + + /** + * Returns the raw JSON value of [paymentFailedAt]. + * + * Unlike [paymentFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = paymentFailedAt + + /** + * Returns the raw JSON value of [paymentStartedAt]. + * + * Unlike [paymentStartedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt + + /** + * Returns the raw JSON value of [scheduledIssueAt]. + * + * Unlike [scheduledIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt + + /** + * Returns the raw JSON value of [shippingAddress]. + * + * Unlike [shippingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField
= shippingAddress + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [syncFailedAt]. + * + * Unlike [syncFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt + + /** + * Returns the raw JSON value of [willAutoIssue]. + * + * Unlike [willAutoIssue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvoiceIssueSummaryResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .memo() + * .metadata() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [InvoiceIssueSummaryResponse]. */ + class Builder internal constructor() { + + 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 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 memo: JsonField? = null + private var metadata: 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 syncFailedAt: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(invoiceIssueSummaryResponse: InvoiceIssueSummaryResponse) = apply { + id = invoiceIssueSummaryResponse.id + amountDue = invoiceIssueSummaryResponse.amountDue + autoCollection = invoiceIssueSummaryResponse.autoCollection + billingAddress = invoiceIssueSummaryResponse.billingAddress + createdAt = invoiceIssueSummaryResponse.createdAt + creditNotes = invoiceIssueSummaryResponse.creditNotes.map { it.toMutableList() } + currency = invoiceIssueSummaryResponse.currency + customer = invoiceIssueSummaryResponse.customer + customerBalanceTransactions = + invoiceIssueSummaryResponse.customerBalanceTransactions.map { it.toMutableList() } + customerTaxId = invoiceIssueSummaryResponse.customerTaxId + dueDate = invoiceIssueSummaryResponse.dueDate + eligibleToIssueAt = invoiceIssueSummaryResponse.eligibleToIssueAt + hostedInvoiceUrl = invoiceIssueSummaryResponse.hostedInvoiceUrl + invoiceDate = invoiceIssueSummaryResponse.invoiceDate + invoiceNumber = invoiceIssueSummaryResponse.invoiceNumber + invoicePdf = invoiceIssueSummaryResponse.invoicePdf + invoiceSource = invoiceIssueSummaryResponse.invoiceSource + issueFailedAt = invoiceIssueSummaryResponse.issueFailedAt + issuedAt = invoiceIssueSummaryResponse.issuedAt + memo = invoiceIssueSummaryResponse.memo + metadata = invoiceIssueSummaryResponse.metadata + paidAt = invoiceIssueSummaryResponse.paidAt + paymentAttempts = invoiceIssueSummaryResponse.paymentAttempts.map { it.toMutableList() } + paymentFailedAt = invoiceIssueSummaryResponse.paymentFailedAt + paymentStartedAt = invoiceIssueSummaryResponse.paymentStartedAt + scheduledIssueAt = invoiceIssueSummaryResponse.scheduledIssueAt + shippingAddress = invoiceIssueSummaryResponse.shippingAddress + status = invoiceIssueSummaryResponse.status + subscription = invoiceIssueSummaryResponse.subscription + syncFailedAt = invoiceIssueSummaryResponse.syncFailedAt + total = invoiceIssueSummaryResponse.total + voidedAt = invoiceIssueSummaryResponse.voidedAt + willAutoIssue = invoiceIssueSummaryResponse.willAutoIssue + additionalProperties = invoiceIssueSummaryResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = 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. + */ + fun amountDue(amountDue: String) = amountDue(JsonField.of(amountDue)) + + /** + * Sets [Builder.amountDue] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } + + fun autoCollection(autoCollection: AutoCollection) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [AutoCollection] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingAddress(billingAddress: Address?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + /** + * Sets [Builder.billingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.billingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingAddress(billingAddress: JsonField
) = apply { + this.billingAddress = billingAddress + } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** A list of credit notes associated with the invoice */ + fun creditNotes(creditNotes: List) = creditNotes(JsonField.of(creditNotes)) + + /** + * Sets [Builder.creditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNotes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNotes(creditNotes: JsonField>) = apply { + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [creditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreditNote(creditNote: CreditNote) = apply { + creditNotes = + (creditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("creditNotes", it).add(creditNote) + } + } + + /** An ISO 4217 currency string or `credits` */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun customerBalanceTransactions( + customerBalanceTransactions: List + ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) + + /** + * Sets [Builder.customerBalanceTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.customerBalanceTransactions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun customerBalanceTransactions( + customerBalanceTransactions: JsonField> + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + /** + * Adds a single [CustomerBalanceTransaction] to [customerBalanceTransactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = + apply { + customerBalanceTransactions = + (customerBalanceTransactions ?: JsonField.of(mutableListOf())).also { + checkKnown("customerBalanceTransactions", it) + .add(customerBalanceTransaction) + } + } + + /** + * 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 | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |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 | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |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) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |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 | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`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 |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |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 | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT 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 | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT 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 | + * |Poland |`pl_nip` |Polish Tax ID 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 | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |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 | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + */ + fun customerTaxId(customerTaxId: CustomerTaxId?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** + * Sets [Builder.customerTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTaxId] with a well-typed [CustomerTaxId] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerTaxId(customerTaxId: JsonField) = apply { + this.customerTaxId = customerTaxId + } + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + fun dueDate(dueDate: OffsetDateTime?) = dueDate(JsonField.ofNullable(dueDate)) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + /** + * 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: OffsetDateTime?) = + eligibleToIssueAt(JsonField.ofNullable(eligibleToIssueAt)) + + /** + * Sets [Builder.eligibleToIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.eligibleToIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun eligibleToIssueAt(eligibleToIssueAt: JsonField) = apply { + this.eligibleToIssueAt = 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. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: String?) = + hostedInvoiceUrl(JsonField.ofNullable(hostedInvoiceUrl)) + + /** + * Sets [Builder.hostedInvoiceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.hostedInvoiceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: JsonField) = apply { + this.hostedInvoiceUrl = hostedInvoiceUrl + } + + /** The scheduled date of the invoice */ + fun invoiceDate(invoiceDate: OffsetDateTime) = invoiceDate(JsonField.of(invoiceDate)) + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = 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. + */ + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** + * Sets [Builder.invoicePdf] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicePdf] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } + + fun invoiceSource(invoiceSource: InvoiceSource) = invoiceSource(JsonField.of(invoiceSource)) + + /** + * Sets [Builder.invoiceSource] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceSource] with a well-typed [InvoiceSource] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceSource(invoiceSource: JsonField) = apply { + this.invoiceSource = 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.) + */ + fun issueFailedAt(issueFailedAt: OffsetDateTime?) = + issueFailedAt(JsonField.ofNullable(issueFailedAt)) + + /** + * Sets [Builder.issueFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issueFailedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issueFailedAt(issueFailedAt: JsonField) = apply { + this.issueFailedAt = 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.) + */ + fun issuedAt(issuedAt: OffsetDateTime?) = issuedAt(JsonField.ofNullable(issuedAt)) + + /** + * Sets [Builder.issuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuedAt(issuedAt: JsonField) = apply { this.issuedAt = issuedAt } + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun memo(memo: JsonField) = apply { this.memo = 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`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** + * Sets [Builder.paidAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paidAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paidAt(paidAt: JsonField) = apply { this.paidAt = paidAt } + + /** A list of payment attempts associated with the invoice */ + fun paymentAttempts(paymentAttempts: List) = + paymentAttempts(JsonField.of(paymentAttempts)) + + /** + * Sets [Builder.paymentAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAttempts] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentAttempts(paymentAttempts: JsonField>) = apply { + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentAttempt] to [paymentAttempts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + paymentAttempts = + (paymentAttempts ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentAttempts", it).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.ofNullable(paymentFailedAt)) + + /** + * Sets [Builder.paymentFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentFailedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentFailedAt(paymentFailedAt: JsonField) = apply { + this.paymentFailedAt = 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. + */ + fun paymentStartedAt(paymentStartedAt: OffsetDateTime?) = + paymentStartedAt(JsonField.ofNullable(paymentStartedAt)) + + /** + * Sets [Builder.paymentStartedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentStartedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentStartedAt(paymentStartedAt: JsonField) = apply { + this.paymentStartedAt = paymentStartedAt + } + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime?) = + scheduledIssueAt(JsonField.ofNullable(scheduledIssueAt)) + + /** + * Sets [Builder.scheduledIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scheduledIssueAt(scheduledIssueAt: JsonField) = apply { + this.scheduledIssueAt = scheduledIssueAt + } + + fun shippingAddress(shippingAddress: Address?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + /** + * Sets [Builder.shippingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingAddress(shippingAddress: JsonField
) = apply { + this.shippingAddress = shippingAddress + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed [SubscriptionMinified] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** + * 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.ofNullable(syncFailedAt)) + + /** + * Sets [Builder.syncFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.syncFailedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun syncFailedAt(syncFailedAt: JsonField) = apply { + this.syncFailedAt = syncFailedAt + } + + /** The total after any minimums and discounts have been applied. */ + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + /** + * This is true if the invoice will be automatically issued in the future, and false + * otherwise. + */ + fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(JsonField.of(willAutoIssue)) + + /** + * Sets [Builder.willAutoIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.willAutoIssue] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun willAutoIssue(willAutoIssue: JsonField) = apply { + this.willAutoIssue = willAutoIssue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InvoiceIssueSummaryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .memo() + * .metadata() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse( + checkRequired("id", id), + checkRequired("amountDue", amountDue), + checkRequired("autoCollection", autoCollection), + checkRequired("billingAddress", billingAddress), + checkRequired("createdAt", createdAt), + checkRequired("creditNotes", creditNotes).map { it.toImmutable() }, + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("customerBalanceTransactions", customerBalanceTransactions).map { + it.toImmutable() + }, + checkRequired("customerTaxId", customerTaxId), + checkRequired("dueDate", dueDate), + checkRequired("eligibleToIssueAt", eligibleToIssueAt), + checkRequired("hostedInvoiceUrl", hostedInvoiceUrl), + checkRequired("invoiceDate", invoiceDate), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("invoicePdf", invoicePdf), + checkRequired("invoiceSource", invoiceSource), + checkRequired("issueFailedAt", issueFailedAt), + checkRequired("issuedAt", issuedAt), + checkRequired("memo", memo), + checkRequired("metadata", metadata), + checkRequired("paidAt", paidAt), + checkRequired("paymentAttempts", paymentAttempts).map { it.toImmutable() }, + checkRequired("paymentFailedAt", paymentFailedAt), + checkRequired("paymentStartedAt", paymentStartedAt), + checkRequired("scheduledIssueAt", scheduledIssueAt), + checkRequired("shippingAddress", shippingAddress), + checkRequired("status", status), + checkRequired("subscription", subscription), + checkRequired("syncFailedAt", syncFailedAt), + checkRequired("total", total), + checkRequired("voidedAt", voidedAt), + checkRequired("willAutoIssue", willAutoIssue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvoiceIssueSummaryResponse = apply { + if (validated) { + return@apply + } + + id() + amountDue() + autoCollection().validate() + billingAddress()?.validate() + createdAt() + creditNotes().forEach { it.validate() } + currency() + customer().validate() + customerBalanceTransactions().forEach { it.validate() } + customerTaxId()?.validate() + dueDate() + eligibleToIssueAt() + hostedInvoiceUrl() + invoiceDate() + invoiceNumber() + invoicePdf() + invoiceSource().validate() + issueFailedAt() + issuedAt() + memo() + metadata().validate() + paidAt() + paymentAttempts().forEach { it.validate() } + paymentFailedAt() + paymentStartedAt() + scheduledIssueAt() + shippingAddress()?.validate() + status().validate() + subscription()?.validate() + syncFailedAt() + total() + voidedAt() + willAutoIssue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (amountDue.asKnown() == null) 0 else 1) + + (autoCollection.asKnown()?.validity() ?: 0) + + (billingAddress.asKnown()?.validity() ?: 0) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditNotes.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (customer.asKnown()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (customerTaxId.asKnown()?.validity() ?: 0) + + (if (dueDate.asKnown() == null) 0 else 1) + + (if (eligibleToIssueAt.asKnown() == null) 0 else 1) + + (if (hostedInvoiceUrl.asKnown() == null) 0 else 1) + + (if (invoiceDate.asKnown() == null) 0 else 1) + + (if (invoiceNumber.asKnown() == null) 0 else 1) + + (if (invoicePdf.asKnown() == null) 0 else 1) + + (invoiceSource.asKnown()?.validity() ?: 0) + + (if (issueFailedAt.asKnown() == null) 0 else 1) + + (if (issuedAt.asKnown() == null) 0 else 1) + + (if (memo.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (paidAt.asKnown() == null) 0 else 1) + + (paymentAttempts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown() == null) 0 else 1) + + (if (paymentStartedAt.asKnown() == null) 0 else 1) + + (if (scheduledIssueAt.asKnown() == null) 0 else 1) + + (shippingAddress.asKnown()?.validity() ?: 0) + + (status.asKnown()?.validity() ?: 0) + + (subscription.asKnown()?.validity() ?: 0) + + (if (syncFailedAt.asKnown() == null) 0 else 1) + + (if (total.asKnown() == null) 0 else 1) + + (if (voidedAt.asKnown() == null) 0 else 1) + + (if (willAutoIssue.asKnown() == null) 0 else 1) + + class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val nextAttemptAt: JsonField, + private val numAttempts: JsonField, + private val previouslyAttemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("next_attempt_at") + @ExcludeMissing + nextAttemptAt: JsonField = JsonMissing.of(), + @JsonProperty("num_attempts") + @ExcludeMissing + numAttempts: JsonField = JsonMissing.of(), + @JsonProperty("previously_attempted_at") + @ExcludeMissing + previouslyAttemptedAt: JsonField = JsonMissing.of(), + ) : this(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, mutableMapOf()) + + /** + * True only if auto-collection is enabled for this invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Boolean? = enabled.getNullable("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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextAttemptAt(): OffsetDateTime? = nextAttemptAt.getNullable("next_attempt_at") + + /** + * Number of auto-collection payment attempts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numAttempts(): Long? = numAttempts.getNullable("num_attempts") + + /** + * 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). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previouslyAttemptedAt(): OffsetDateTime? = + previouslyAttemptedAt.getNullable("previously_attempted_at") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [nextAttemptAt]. + * + * Unlike [nextAttemptAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt + + /** + * Returns the raw JSON value of [numAttempts]. + * + * Unlike [numAttempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_attempts") + @ExcludeMissing + fun _numAttempts(): JsonField = numAttempts + + /** + * Returns the raw JSON value of [previouslyAttemptedAt]. + * + * Unlike [previouslyAttemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previously_attempted_at") + @ExcludeMissing + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoCollection]. + * + * The following fields are required: + * ```kotlin + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [AutoCollection]. */ + class Builder internal constructor() { + + 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() + + internal fun from(autoCollection: AutoCollection) = apply { + enabled = autoCollection.enabled + nextAttemptAt = autoCollection.nextAttemptAt + numAttempts = autoCollection.numAttempts + previouslyAttemptedAt = autoCollection.previouslyAttemptedAt + additionalProperties = autoCollection.additionalProperties.toMutableMap() + } + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** + * Alias for [Builder.enabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = 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`. + */ + fun nextAttemptAt(nextAttemptAt: OffsetDateTime?) = + nextAttemptAt(JsonField.ofNullable(nextAttemptAt)) + + /** + * Sets [Builder.nextAttemptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.nextAttemptAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextAttemptAt(nextAttemptAt: JsonField) = apply { + this.nextAttemptAt = nextAttemptAt + } + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** + * Alias for [Builder.numAttempts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** + * Sets [Builder.numAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.numAttempts] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numAttempts(numAttempts: JsonField) = apply { this.numAttempts = numAttempts } + + /** + * 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: OffsetDateTime?) = + previouslyAttemptedAt(JsonField.ofNullable(previouslyAttemptedAt)) + + /** + * Sets [Builder.previouslyAttemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.previouslyAttemptedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: JsonField) = apply { + this.previouslyAttemptedAt = previouslyAttemptedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoCollection]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoCollection = + AutoCollection( + checkRequired("enabled", enabled), + checkRequired("nextAttemptAt", nextAttemptAt), + checkRequired("numAttempts", numAttempts), + checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoCollection = apply { + if (validated) { + return@apply + } + + enabled() + nextAttemptAt() + numAttempts() + previouslyAttemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (enabled.asKnown() == null) 0 else 1) + + (if (nextAttemptAt.asKnown() == null) 0 else 1) + + (if (numAttempts.asKnown() == null) 0 else 1) + + (if (previouslyAttemptedAt.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + } + + class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val creditNoteNumber: JsonField, + private val memo: JsonField, + private val reason: JsonField, + private val total: JsonField, + private val type: JsonField, + private val voidedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + ) : this(id, creditNoteNumber, memo, reason, total, type, voidedAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** + * An optional memo supplied on the credit note. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): String? = memo.getNullable("memo") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): String = total.getRequired("total") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): String = type.getRequired("type") + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit note + * was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voidedAt(): OffsetDateTime? = voidedAt.getNullable("voided_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creditNoteNumber]. + * + * Unlike [creditNoteNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditNote]. + * + * The following fields are required: + * ```kotlin + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CreditNote]. */ + class Builder internal constructor() { + + 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() + + internal fun from(creditNote: CreditNote) = apply { + id = creditNote.id + creditNoteNumber = creditNote.creditNoteNumber + memo = creditNote.memo + reason = creditNote.reason + total = creditNote.total + type = creditNote.type + voidedAt = creditNote.voidedAt + additionalProperties = creditNote.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun creditNoteNumber(creditNoteNumber: String) = + creditNoteNumber(JsonField.of(creditNoteNumber)) + + /** + * Sets [Builder.creditNoteNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNoteNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNoteNumber(creditNoteNumber: JsonField) = apply { + this.creditNoteNumber = creditNoteNumber + } + + /** An optional memo supplied on the credit note. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * 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.ofNullable(voidedAt)) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditNote]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditNote = + CreditNote( + checkRequired("id", id), + checkRequired("creditNoteNumber", creditNoteNumber), + checkRequired("memo", memo), + checkRequired("reason", reason), + checkRequired("total", total), + checkRequired("type", type), + checkRequired("voidedAt", voidedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditNote = apply { + if (validated) { + return@apply + } + + id() + creditNoteNumber() + memo() + reason() + total() + type() + voidedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (creditNoteNumber.asKnown() == null) 0 else 1) + + (if (memo.asKnown() == null) 0 else 1) + + (if (reason.asKnown() == null) 0 else 1) + + (if (total.asKnown() == null) 0 else 1) + + (if (type.asKnown() == null) 0 else 1) + + (if (voidedAt.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNote{id=$id, creditNoteNumber=$creditNoteNumber, memo=$memo, reason=$reason, total=$total, type=$type, voidedAt=$voidedAt, additionalProperties=$additionalProperties}" + } + + class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val action: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val creditNote: JsonField, + private val description: JsonField, + private val endingBalance: JsonField, + private val invoice: JsonField, + private val startingBalance: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("action") @ExcludeMissing action: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_note") + @ExcludeMissing + creditNote: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + mutableMapOf(), + ) + + /** + * A unique id for this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The value of the amount changed in the transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The creation time of this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditNote(): CreditNoteTiny? = creditNote.getNullable("credit_note") + + /** + * An optional description provided for manual customer balance adjustments. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): String? = description.getNullable("description") + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endingBalance(): String = endingBalance.getRequired("ending_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoice(): InvoiceTiny? = invoice.getNullable("invoice") + + /** + * The original value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingBalance(): String = startingBalance.getRequired("starting_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNote]. + * + * Unlike [creditNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransaction]. + * + * The following fields are required: + * ```kotlin + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CustomerBalanceTransaction]. */ + class Builder internal constructor() { + + 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() + + internal fun from(customerBalanceTransaction: CustomerBalanceTransaction) = apply { + id = customerBalanceTransaction.id + action = customerBalanceTransaction.action + amount = customerBalanceTransaction.amount + createdAt = customerBalanceTransaction.createdAt + creditNote = customerBalanceTransaction.creditNote + description = customerBalanceTransaction.description + endingBalance = customerBalanceTransaction.endingBalance + invoice = customerBalanceTransaction.invoice + startingBalance = customerBalanceTransaction.startingBalance + type = customerBalanceTransaction.type + additionalProperties = + customerBalanceTransaction.additionalProperties.toMutableMap() + } + + /** A unique id for this transaction. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** The value of the amount changed in the transaction. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The creation time of this transaction. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditNote(creditNote: CreditNoteTiny?) = + creditNote(JsonField.ofNullable(creditNote)) + + /** + * Sets [Builder.creditNote] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNote] with a well-typed [CreditNoteTiny] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNote(creditNote: JsonField) = apply { + this.creditNote = creditNote + } + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + */ + fun endingBalance(endingBalance: String) = endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + fun invoice(invoice: InvoiceTiny?) = invoice(JsonField.ofNullable(invoice)) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [InvoiceTiny] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + /** + * The original value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + fun startingBalance(startingBalance: String) = + startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomerBalanceTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerBalanceTransaction = + CustomerBalanceTransaction( + checkRequired("id", id), + checkRequired("action", action), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditNote", creditNote), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("invoice", invoice), + checkRequired("startingBalance", startingBalance), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerBalanceTransaction = apply { + if (validated) { + return@apply + } + + id() + action().validate() + amount() + createdAt() + creditNote()?.validate() + description() + endingBalance() + invoice()?.validate() + startingBalance() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (action.asKnown()?.validity() ?: 0) + + (if (amount.asKnown() == null) 0 else 1) + + (if (createdAt.asKnown() == null) 0 else 1) + + (creditNote.asKnown()?.validity() ?: 0) + + (if (description.asKnown() == null) 0 else 1) + + (if (endingBalance.asKnown() == null) 0 else 1) + + (invoice.asKnown()?.validity() ?: 0) + + (if (startingBalance.asKnown() == null) 0 else 1) + + (type.asKnown()?.validity() ?: 0) + + class Action @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val APPLIED_TO_INVOICE = of("applied_to_invoice") + + val MANUAL_ADJUSTMENT = of("manual_adjustment") + + val PRORATED_REFUND = of("prorated_refund") + + val REVERT_PRORATED_REFUND = of("revert_prorated_refund") + + val RETURN_FROM_VOIDING = of("return_from_voiding") + + val CREDIT_NOTE_APPLIED = of("credit_note_applied") + + val CREDIT_NOTE_VOIDED = of("credit_note_voided") + + val OVERPAYMENT_REFUND = of("overpayment_refund") + + val EXTERNAL_PAYMENT = of("external_payment") + + val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + + fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + /** + * An enum member indicating that [Action] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPLIED_TO_INVOICE -> Value.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Value.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Value.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Value.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Value.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Value.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPLIED_TO_INVOICE -> Known.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Known.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Known.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Known.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Known.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Known.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER + else -> throw OrbInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val INCREMENT = of("increment") + + val DECREMENT = of("decrement") + + fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INCREMENT, + DECREMENT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCREMENT, + DECREMENT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCREMENT -> Value.INCREMENT + DECREMENT -> Value.DECREMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCREMENT -> Known.INCREMENT + DECREMENT -> Known.DECREMENT + else -> throw OrbInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomerBalanceTransaction && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerBalanceTransaction{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" + } + + class InvoiceSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val SUBSCRIPTION = of("subscription") + + val PARTIAL = of("partial") + + val ONE_OFF = of("one_off") + + fun of(value: String) = InvoiceSource(JsonField.of(value)) + } + + /** An enum containing [InvoiceSource]'s known values. */ + enum class Known { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + } + + /** + * An enum containing [InvoiceSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InvoiceSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + /** + * An enum member indicating that [InvoiceSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUBSCRIPTION -> Value.SUBSCRIPTION + PARTIAL -> Value.PARTIAL + ONE_OFF -> Value.ONE_OFF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + PARTIAL -> Known.PARTIAL + ONE_OFF -> Known.ONE_OFF + else -> throw OrbInvalidDataException("Unknown InvoiceSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): InvoiceSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val paymentProvider: JsonField, + private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, + private val succeeded: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), + @JsonProperty("succeeded") + @ExcludeMissing + succeeded: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + mutableMapOf(), + ) + + /** + * The ID of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The time at which the payment attempt was created. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The payment provider that attempted to collect the payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProvider(): PaymentProvider? = paymentProvider.getNullable("payment_provider") + + /** + * The ID of the payment attempt in the payment provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviderId(): String? = paymentProviderId.getNullable("payment_provider_id") + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for payment + * attempts that did not succeed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun receiptPdf(): String? = receiptPdf.getNullable("receipt_pdf") + + /** + * Whether the payment attempt succeeded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun succeeded(): Boolean = succeeded.getRequired("succeeded") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [paymentProvider]. + * + * Unlike [paymentProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** + * Returns the raw JSON value of [paymentProviderId]. + * + * Unlike [paymentProviderId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + /** + * Returns the raw JSON value of [receiptPdf]. + * + * Unlike [receiptPdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("receipt_pdf") + @ExcludeMissing + fun _receiptPdf(): JsonField = receiptPdf + + /** + * Returns the raw JSON value of [succeeded]. + * + * Unlike [succeeded], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentAttempt]. + * + * The following fields are required: + * ```kotlin + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PaymentAttempt]. */ + class Builder internal constructor() { + + 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 receiptPdf: JsonField? = null + private var succeeded: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentAttempt: PaymentAttempt) = apply { + id = paymentAttempt.id + amount = paymentAttempt.amount + createdAt = paymentAttempt.createdAt + paymentProvider = paymentAttempt.paymentProvider + paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf + succeeded = paymentAttempt.succeeded + additionalProperties = paymentAttempt.additionalProperties.toMutableMap() + } + + /** The ID of the payment attempt. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the payment attempt. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The time at which the payment attempt was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** + * Sets [Builder.paymentProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProvider] with a well-typed [PaymentProvider] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * Sets [Builder.paymentProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + */ + fun receiptPdf(receiptPdf: String?) = receiptPdf(JsonField.ofNullable(receiptPdf)) + + /** + * Sets [Builder.receiptPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptPdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun receiptPdf(receiptPdf: JsonField) = apply { this.receiptPdf = receiptPdf } + + /** Whether the payment attempt succeeded. */ + fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) + + /** + * Sets [Builder.succeeded] to an arbitrary JSON value. + * + * You should usually call [Builder.succeeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun succeeded(succeeded: JsonField) = apply { this.succeeded = succeeded } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentAttempt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentAttempt = + PaymentAttempt( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("paymentProvider", paymentProvider), + checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), + checkRequired("succeeded", succeeded), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentAttempt = apply { + if (validated) { + return@apply + } + + id() + amount() + createdAt() + paymentProvider()?.validate() + paymentProviderId() + receiptPdf() + succeeded() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (amount.asKnown() == null) 0 else 1) + + (if (createdAt.asKnown() == null) 0 else 1) + + (paymentProvider.asKnown()?.validity() ?: 0) + + (if (paymentProviderId.asKnown() == null) 0 else 1) + + (if (receiptPdf.asKnown() == null) 0 else 1) + + (if (succeeded.asKnown() == null) 0 else 1) + + /** The payment provider that attempted to collect the payment. */ + class PaymentProvider + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val STRIPE = of("stripe") + + fun of(value: String) = PaymentProvider(JsonField.of(value)) + } + + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [PaymentProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentProvider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [PaymentProvider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentAttempt && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + receiptPdf == other.receiptPdf && + succeeded == other.succeeded && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, receiptPdf=$receiptPdf, succeeded=$succeeded, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ISSUED = of("issued") + + val PAID = of("paid") + + val SYNCED = of("synced") + + val VOID = of("void") + + val DRAFT = of("draft") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceIssueSummaryResponse && + id == other.id && + amountDue == other.amountDue && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + creditNotes == other.creditNotes && + currency == other.currency && + customer == other.customer && + customerBalanceTransactions == other.customerBalanceTransactions && + customerTaxId == other.customerTaxId && + dueDate == other.dueDate && + eligibleToIssueAt == other.eligibleToIssueAt && + hostedInvoiceUrl == other.hostedInvoiceUrl && + invoiceDate == other.invoiceDate && + invoiceNumber == other.invoiceNumber && + invoicePdf == other.invoicePdf && + invoiceSource == other.invoiceSource && + issueFailedAt == other.issueFailedAt && + issuedAt == other.issuedAt && + memo == other.memo && + metadata == other.metadata && + paidAt == other.paidAt && + paymentAttempts == other.paymentAttempts && + paymentFailedAt == other.paymentFailedAt && + paymentStartedAt == other.paymentStartedAt && + scheduledIssueAt == other.scheduledIssueAt && + shippingAddress == other.shippingAddress && + status == other.status && + subscription == other.subscription && + syncFailedAt == other.syncFailedAt && + total == other.total && + voidedAt == other.voidedAt && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + memo, + metadata, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceIssueSummaryResponse{id=$id, amountDue=$amountDue, autoCollection=$autoCollection, billingAddress=$billingAddress, createdAt=$createdAt, creditNotes=$creditNotes, currency=$currency, customer=$customer, customerBalanceTransactions=$customerBalanceTransactions, customerTaxId=$customerTaxId, dueDate=$dueDate, eligibleToIssueAt=$eligibleToIssueAt, hostedInvoiceUrl=$hostedInvoiceUrl, invoiceDate=$invoiceDate, invoiceNumber=$invoiceNumber, invoicePdf=$invoicePdf, invoiceSource=$invoiceSource, issueFailedAt=$issueFailedAt, issuedAt=$issuedAt, memo=$memo, metadata=$metadata, paidAt=$paidAt, paymentAttempts=$paymentAttempts, paymentFailedAt=$paymentFailedAt, paymentStartedAt=$paymentStartedAt, scheduledIssueAt=$scheduledIssueAt, shippingAddress=$shippingAddress, status=$status, subscription=$subscription, syncFailedAt=$syncFailedAt, total=$total, voidedAt=$voidedAt, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt new file mode 100644 index 000000000..11b2598a6 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt @@ -0,0 +1,744 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects + +/** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified date + * in the customer's timezone. Otherwise, the activation time will default to the **start** of the + * current day in the customer's timezone. + */ +class LicenseCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The external identifier for the license. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = body.externalLicenseId() + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = body.licenseTypeId() + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = body.subscriptionId() + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): LocalDate? = body.endDate() + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun startDate(): LocalDate? = body.startDate() + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _externalLicenseId(): JsonField = body._externalLicenseId() + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _licenseTypeId(): JsonField = body._licenseTypeId() + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _subscriptionId(): JsonField = body._subscriptionId() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startDate(): JsonField = body._startDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseCreateParams]. + * + * The following fields are required: + * ```kotlin + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseCreateParams: LicenseCreateParams) = apply { + body = licenseCreateParams.body.toBuilder() + additionalHeaders = licenseCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [externalLicenseId] + * - [licenseTypeId] + * - [subscriptionId] + * - [endDate] + * - [startDate] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The external identifier for the license. */ + fun externalLicenseId(externalLicenseId: String) = apply { + body.externalLicenseId(externalLicenseId) + } + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + body.externalLicenseId(externalLicenseId) + } + + fun licenseTypeId(licenseTypeId: String) = apply { body.licenseTypeId(licenseTypeId) } + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + body.licenseTypeId(licenseTypeId) + } + + fun subscriptionId(subscriptionId: String) = apply { body.subscriptionId(subscriptionId) } + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + body.subscriptionId(subscriptionId) + } + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + */ + fun endDate(endDate: LocalDate?) = apply { body.endDate(endDate) } + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + */ + fun startDate(startDate: LocalDate?) = apply { body.startDate(startDate) } + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseCreateParams = + LicenseCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val subscriptionId: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + externalLicenseId, + licenseTypeId, + subscriptionId, + endDate, + startDate, + mutableMapOf(), + ) + + /** + * The external identifier for the license. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): LocalDate? = endDate.getNullable("end_date") + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startDate(): LocalDate? = startDate.getNullable("start_date") + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```kotlin + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var subscriptionId: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(body: Body) = apply { + externalLicenseId = body.externalLicenseId + licenseTypeId = body.licenseTypeId + subscriptionId = body.subscriptionId + endDate = body.endDate + startDate = body.startDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The external identifier for the license. */ + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + */ + fun endDate(endDate: LocalDate?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + */ + fun startDate(startDate: LocalDate?) = startDate(JsonField.ofNullable(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + endDate, + startDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + externalLicenseId() + licenseTypeId() + subscriptionId() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + endDate, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt new file mode 100644 index 000000000..2fd6f444d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class LicenseCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): OffsetDateTime? = endDate.getNullable("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseCreateResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseCreateResponse: LicenseCreateResponse) = apply { + id = licenseCreateResponse.id + endDate = licenseCreateResponse.endDate + externalLicenseId = licenseCreateResponse.externalLicenseId + licenseTypeId = licenseCreateResponse.licenseTypeId + startDate = licenseCreateResponse.startDate + status = licenseCreateResponse.status + subscriptionId = licenseCreateResponse.subscriptionId + additionalProperties = licenseCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseCreateResponse = + LicenseCreateResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseCreateResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val INACTIVE = of("inactive") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseCreateResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseCreateResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt new file mode 100644 index 000000000..7a7e5db3d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt @@ -0,0 +1,419 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects + +/** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** of + * the current day in the customer's timezone. + */ +class LicenseDeactivateParams +private constructor( + private val licenseId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): String? = licenseId + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): LocalDate? = body.endDate() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): LicenseDeactivateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseDeactivateParams]. */ + fun builder() = Builder() + } + + /** A builder for [LicenseDeactivateParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseDeactivateParams: LicenseDeactivateParams) = apply { + licenseId = licenseDeactivateParams.licenseId + body = licenseDeactivateParams.body.toBuilder() + additionalHeaders = licenseDeactivateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseDeactivateParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endDate] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + */ + fun endDate(endDate: LocalDate?) = apply { body.endDate(endDate) } + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + 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) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseDeactivateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseDeactivateParams = + LicenseDeactivateParams( + licenseId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of() + ) : this(endDate, mutableMapOf()) + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): LocalDate? = endDate.getNullable("end_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(body: Body) = apply { + endDate = body.endDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in + * the customer's timezone. + */ + fun endDate(endDate: LocalDate?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endDate, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (endDate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endDate == other.endDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endDate=$endDate, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseDeactivateParams && + licenseId == other.licenseId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(licenseId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseDeactivateParams{licenseId=$licenseId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt new file mode 100644 index 000000000..df5dbc90f --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class LicenseDeactivateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): OffsetDateTime? = endDate.getNullable("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseDeactivateResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseDeactivateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseDeactivateResponse: LicenseDeactivateResponse) = apply { + id = licenseDeactivateResponse.id + endDate = licenseDeactivateResponse.endDate + externalLicenseId = licenseDeactivateResponse.externalLicenseId + licenseTypeId = licenseDeactivateResponse.licenseTypeId + startDate = licenseDeactivateResponse.startDate + status = licenseDeactivateResponse.status + subscriptionId = licenseDeactivateResponse.subscriptionId + additionalProperties = licenseDeactivateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseDeactivateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseDeactivateResponse = + LicenseDeactivateResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseDeactivateResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val INACTIVE = of("inactive") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseDeactivateResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseDeactivateResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt new file mode 100644 index 000000000..40f4818ff --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects + +/** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseExternalLicenseGetUsageParams +private constructor( + private val externalLicenseId: String?, + private val licenseTypeId: String, + private val subscriptionId: String, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun externalLicenseId(): String? = externalLicenseId + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(): String = licenseTypeId + + /** The subscription ID to get license usage for. */ + fun subscriptionId(): String = subscriptionId + + /** Pagination cursor from a previous request. */ + fun cursor(): String? = cursor + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): LocalDate? = endDate + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): List? = groupBy + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Long? = limit + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): LocalDate? = startDate + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseExternalLicenseGetUsageParams]. + * + * The following fields are required: + * ```kotlin + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseExternalLicenseGetUsageParams]. */ + class Builder internal constructor() { + + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from( + licenseExternalLicenseGetUsageParams: LicenseExternalLicenseGetUsageParams + ) = apply { + externalLicenseId = licenseExternalLicenseGetUsageParams.externalLicenseId + licenseTypeId = licenseExternalLicenseGetUsageParams.licenseTypeId + subscriptionId = licenseExternalLicenseGetUsageParams.subscriptionId + cursor = licenseExternalLicenseGetUsageParams.cursor + endDate = licenseExternalLicenseGetUsageParams.endDate + groupBy = licenseExternalLicenseGetUsageParams.groupBy?.toMutableList() + limit = licenseExternalLicenseGetUsageParams.limit + startDate = licenseExternalLicenseGetUsageParams.startDate + additionalHeaders = licenseExternalLicenseGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = + licenseExternalLicenseGetUsageParams.additionalQueryParams.toBuilder() + } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The subscription ID to get license usage for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseExternalLicenseGetUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseExternalLicenseGetUsageParams = + LicenseExternalLicenseGetUsageParams( + externalLicenseId, + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> externalLicenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseExternalLicenseGetUsageParams && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseExternalLicenseGetUsageParams{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt new file mode 100644 index 000000000..a850c490e --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt @@ -0,0 +1,933 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects + +class LicenseExternalLicenseGetUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseExternalLicenseGetUsageResponse]. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseExternalLicenseGetUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + licenseExternalLicenseGetUsageResponse: LicenseExternalLicenseGetUsageResponse + ) = apply { + data = licenseExternalLicenseGetUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseExternalLicenseGetUsageResponse.paginationMetadata + additionalProperties = + licenseExternalLicenseGetUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseExternalLicenseGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseExternalLicenseGetUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Double? = + allocationEligibleCredits.getNullable("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): String? = externalLicenseId.getNullable("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): String? = licenseId.getNullable("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Double? = sharedPoolCredits.getNullable("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```kotlin + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocatedCredits.asKnown() == null) 0 else 1) + + (if (consumedCredits.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (pricingUnit.asKnown() == null) 0 else 1) + + (if (remainingCredits.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + (if (allocationEligibleCredits.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseId.asKnown() == null) 0 else 1) + + (if (sharedPoolCredits.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseExternalLicenseGetUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseExternalLicenseGetUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt new file mode 100644 index 000000000..b944ebe7d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page +import com.withorb.api.core.checkRequired +import com.withorb.api.services.blocking.LicenseService +import java.util.Objects + +/** @see LicenseService.list */ +class LicenseListPage +private constructor( + private val service: LicenseService, + private val params: LicenseListParams, + private val response: LicenseListPageResponse, +) : Page { + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.data + */ + fun data(): List = response._data().getNullable("data") ?: emptyList() + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.paginationMetadata + */ + fun paginationMetadata(): PaginationMetadata? = + response._paginationMetadata().getNullable("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } != null + + fun nextPageParams(): LicenseListParams { + val nextCursor = + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): LicenseListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPage]. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseListPage]. */ + class Builder internal constructor() { + + private var service: LicenseService? = null + private var params: LicenseListParams? = null + private var response: LicenseListPageResponse? = null + + internal fun from(licenseListPage: LicenseListPage) = apply { + service = licenseListPage.service + params = licenseListPage.params + response = licenseListPage.response + } + + fun service(service: LicenseService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPage = + LicenseListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseListPage{service=$service, params=$params, response=$response}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt new file mode 100644 index 000000000..8fe2d545d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync +import com.withorb.api.core.checkRequired +import com.withorb.api.services.async.LicenseServiceAsync +import java.util.Objects + +/** @see LicenseServiceAsync.list */ +class LicenseListPageAsync +private constructor( + private val service: LicenseServiceAsync, + private val params: LicenseListParams, + private val response: LicenseListPageResponse, +) : PageAsync { + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.data + */ + fun data(): List = response._data().getNullable("data") ?: emptyList() + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.paginationMetadata + */ + fun paginationMetadata(): PaginationMetadata? = + response._paginationMetadata().getNullable("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } != null + + fun nextPageParams(): LicenseListParams { + val nextCursor = + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override suspend fun nextPage(): LicenseListPageAsync = service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPageAsync]. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseListPageAsync]. */ + class Builder internal constructor() { + + private var service: LicenseServiceAsync? = null + private var params: LicenseListParams? = null + private var response: LicenseListPageResponse? = null + + internal fun from(licenseListPageAsync: LicenseListPageAsync) = apply { + service = licenseListPageAsync.service + params = licenseListPageAsync.params + response = licenseListPageAsync.response + } + + fun service(service: LicenseServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPageAsync = + LicenseListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPageAsync && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseListPageAsync{service=$service, params=$params, response=$response}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt new file mode 100644 index 000000000..f0d0d8419 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +class LicenseListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPageResponse]. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseListPageResponse: LicenseListPageResponse) = apply { + data = licenseListPageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseListPageResponse.paginationMetadata + additionalProperties = licenseListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: LicenseListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPageResponse = + LicenseListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseListPageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt new file mode 100644 index 000000000..0e751e77a --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt @@ -0,0 +1,407 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.withorb.api.core.Enum +import com.withorb.api.core.JsonField +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +/** This endpoint returns a list of all licenses for a subscription. */ +class LicenseListParams +private constructor( + private val subscriptionId: String, + private val cursor: String?, + private val externalLicenseId: String?, + private val licenseTypeId: String?, + private val limit: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun subscriptionId(): String = subscriptionId + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(): String? = cursor + + fun externalLicenseId(): String? = externalLicenseId + + fun licenseTypeId(): String? = licenseTypeId + + /** The number of items to fetch. Defaults to 20. */ + fun limit(): Long? = limit + + fun status(): Status? = status + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListParams]. + * + * The following fields are required: + * ```kotlin + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseListParams]. */ + class Builder internal constructor() { + + private var subscriptionId: String? = null + private var cursor: String? = null + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var limit: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseListParams: LicenseListParams) = apply { + subscriptionId = licenseListParams.subscriptionId + cursor = licenseListParams.cursor + externalLicenseId = licenseListParams.externalLicenseId + licenseTypeId = licenseListParams.licenseTypeId + limit = licenseListParams.limit + status = licenseListParams.status + additionalHeaders = licenseListParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseListParams.additionalQueryParams.toBuilder() + } + + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String?) = apply { this.licenseTypeId = licenseTypeId } + + /** The number of items to fetch. Defaults to 20. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + fun status(status: Status?) = apply { this.status = status } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListParams = + LicenseListParams( + checkRequired("subscriptionId", subscriptionId), + cursor, + externalLicenseId, + licenseTypeId, + limit, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + externalLicenseId?.let { put("external_license_id", it) } + licenseTypeId?.let { put("license_type_id", it) } + limit?.let { put("limit", it.toString()) } + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val INACTIVE = of("inactive") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListParams && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + cursor, + externalLicenseId, + licenseTypeId, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseListParams{subscriptionId=$subscriptionId, cursor=$cursor, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt new file mode 100644 index 000000000..222730ec1 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class LicenseListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): OffsetDateTime? = endDate.getNullable("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseListResponse: LicenseListResponse) = apply { + id = licenseListResponse.id + endDate = licenseListResponse.endDate + externalLicenseId = licenseListResponse.externalLicenseId + licenseTypeId = licenseListResponse.licenseTypeId + startDate = licenseListResponse.startDate + status = licenseListResponse.status + subscriptionId = licenseListResponse.subscriptionId + additionalProperties = licenseListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListResponse = + LicenseListResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseListResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val INACTIVE = of("inactive") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseListResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt new file mode 100644 index 000000000..d9efde60b --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +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 license given an external license identifier. */ +class LicenseRetrieveByExternalIdParams +private constructor( + private val externalLicenseId: String?, + private val licenseTypeId: String, + private val subscriptionId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun externalLicenseId(): String? = externalLicenseId + + /** The ID of the license type to fetch the license for. */ + fun licenseTypeId(): String = licenseTypeId + + /** The ID of the subscription to fetch the license for. */ + fun subscriptionId(): String = subscriptionId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseRetrieveByExternalIdParams]. + * + * The following fields are required: + * ```kotlin + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveByExternalIdParams]. */ + class Builder internal constructor() { + + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseRetrieveByExternalIdParams: LicenseRetrieveByExternalIdParams) = + apply { + externalLicenseId = licenseRetrieveByExternalIdParams.externalLicenseId + licenseTypeId = licenseRetrieveByExternalIdParams.licenseTypeId + subscriptionId = licenseRetrieveByExternalIdParams.subscriptionId + additionalHeaders = licenseRetrieveByExternalIdParams.additionalHeaders.toBuilder() + additionalQueryParams = + licenseRetrieveByExternalIdParams.additionalQueryParams.toBuilder() + } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The ID of the license type to fetch the license for. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The ID of the subscription to fetch the license for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseRetrieveByExternalIdParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveByExternalIdParams = + LicenseRetrieveByExternalIdParams( + externalLicenseId, + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> externalLicenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveByExternalIdParams && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseRetrieveByExternalIdParams{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt new file mode 100644 index 000000000..6815f7da5 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt @@ -0,0 +1,549 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class LicenseRetrieveByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): OffsetDateTime? = endDate.getNullable("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseRetrieveByExternalIdResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveByExternalIdResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + licenseRetrieveByExternalIdResponse: LicenseRetrieveByExternalIdResponse + ) = apply { + id = licenseRetrieveByExternalIdResponse.id + endDate = licenseRetrieveByExternalIdResponse.endDate + externalLicenseId = licenseRetrieveByExternalIdResponse.externalLicenseId + licenseTypeId = licenseRetrieveByExternalIdResponse.licenseTypeId + startDate = licenseRetrieveByExternalIdResponse.startDate + status = licenseRetrieveByExternalIdResponse.status + subscriptionId = licenseRetrieveByExternalIdResponse.subscriptionId + additionalProperties = + licenseRetrieveByExternalIdResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseRetrieveByExternalIdResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseRetrieveByExternalIdResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val INACTIVE = of("inactive") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveByExternalIdResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseRetrieveByExternalIdResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt new file mode 100644 index 000000000..9826fa041 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +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 license given an identifier. */ +class LicenseRetrieveParams +private constructor( + private val licenseId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): String? = licenseId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): LicenseRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseRetrieveParams]. */ + fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseRetrieveParams: LicenseRetrieveParams) = apply { + licenseId = licenseRetrieveParams.licenseId + additionalHeaders = licenseRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseRetrieveParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseRetrieveParams = + LicenseRetrieveParams( + licenseId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveParams && + licenseId == other.licenseId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(licenseId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseRetrieveParams{licenseId=$licenseId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt new file mode 100644 index 000000000..c887d7be7 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +class LicenseRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): OffsetDateTime? = endDate.getNullable("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseRetrieveResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseRetrieveResponse: LicenseRetrieveResponse) = apply { + id = licenseRetrieveResponse.id + endDate = licenseRetrieveResponse.endDate + externalLicenseId = licenseRetrieveResponse.externalLicenseId + licenseTypeId = licenseRetrieveResponse.licenseTypeId + startDate = licenseRetrieveResponse.startDate + status = licenseRetrieveResponse.status + subscriptionId = licenseRetrieveResponse.subscriptionId + additionalProperties = licenseRetrieveResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveResponse = + LicenseRetrieveResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (status.asKnown()?.validity() ?: 0) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + val ACTIVE = of("active") + + val INACTIVE = of("inactive") + + fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString() ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseRetrieveResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt new file mode 100644 index 000000000..9d3d06042 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt @@ -0,0 +1,501 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ +class LicenseTypeCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = body.groupingKey() + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupingKey(): JsonField = body._groupingKey() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeCreateParams]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseTypeCreateParams: LicenseTypeCreateParams) = apply { + body = licenseTypeCreateParams.body.toBuilder() + additionalHeaders = licenseTypeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [groupingKey] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = apply { body.groupingKey(groupingKey) } + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { body.groupingKey(groupingKey) } + + /** The name of the license type. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + 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) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeCreateParams = + LicenseTypeCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(groupingKey, name, mutableMapOf()) + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(body: Body) = apply { + groupingKey = body.groupingKey + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt new file mode 100644 index 000000000..d308082ac --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeCreateResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseTypeCreateResponse: LicenseTypeCreateResponse) = apply { + id = licenseTypeCreateResponse.id + groupingKey = licenseTypeCreateResponse.groupingKey + name = licenseTypeCreateResponse.name + additionalProperties = licenseTypeCreateResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeCreateResponse = + LicenseTypeCreateResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeCreateResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeCreateResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeCreateResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt new file mode 100644 index 000000000..fe133a33c --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page +import com.withorb.api.core.checkRequired +import com.withorb.api.services.blocking.LicenseTypeService +import java.util.Objects + +/** @see LicenseTypeService.list */ +class LicenseTypeListPage +private constructor( + private val service: LicenseTypeService, + private val params: LicenseTypeListParams, + private val response: LicenseTypeListPageResponse, +) : Page { + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.data + */ + fun data(): List = response._data().getNullable("data") ?: emptyList() + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.paginationMetadata + */ + fun paginationMetadata(): PaginationMetadata? = + response._paginationMetadata().getNullable("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } != null + + fun nextPageParams(): LicenseTypeListParams { + val nextCursor = + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): LicenseTypeListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseTypeListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseTypeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPage]. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPage]. */ + class Builder internal constructor() { + + private var service: LicenseTypeService? = null + private var params: LicenseTypeListParams? = null + private var response: LicenseTypeListPageResponse? = null + + internal fun from(licenseTypeListPage: LicenseTypeListPage) = apply { + service = licenseTypeListPage.service + params = licenseTypeListPage.params + response = licenseTypeListPage.response + } + + fun service(service: LicenseTypeService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseTypeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseTypeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseTypeListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPage = + LicenseTypeListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseTypeListPage{service=$service, params=$params, response=$response}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt new file mode 100644 index 000000000..ebc0d02d0 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync +import com.withorb.api.core.checkRequired +import com.withorb.api.services.async.LicenseTypeServiceAsync +import java.util.Objects + +/** @see LicenseTypeServiceAsync.list */ +class LicenseTypeListPageAsync +private constructor( + private val service: LicenseTypeServiceAsync, + private val params: LicenseTypeListParams, + private val response: LicenseTypeListPageResponse, +) : PageAsync { + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.data + */ + fun data(): List = response._data().getNullable("data") ?: emptyList() + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.paginationMetadata + */ + fun paginationMetadata(): PaginationMetadata? = + response._paginationMetadata().getNullable("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } != null + + fun nextPageParams(): LicenseTypeListParams { + val nextCursor = + paginationMetadata()?.let { it._nextCursor().getNullable("next_cursor") } + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override suspend fun nextPage(): LicenseTypeListPageAsync = service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseTypeListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseTypeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPageAsync]. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPageAsync]. */ + class Builder internal constructor() { + + private var service: LicenseTypeServiceAsync? = null + private var params: LicenseTypeListParams? = null + private var response: LicenseTypeListPageResponse? = null + + internal fun from(licenseTypeListPageAsync: LicenseTypeListPageAsync) = apply { + service = licenseTypeListPageAsync.service + params = licenseTypeListPageAsync.params + response = licenseTypeListPageAsync.response + } + + fun service(service: LicenseTypeServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseTypeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseTypeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseTypeListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPageAsync = + LicenseTypeListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPageAsync && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseTypeListPageAsync{service=$service, params=$params, response=$response}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt new file mode 100644 index 000000000..7e9aa3fe3 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +class LicenseTypeListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPageResponse]. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseTypeListPageResponse: LicenseTypeListPageResponse) = apply { + data = licenseTypeListPageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseTypeListPageResponse.paginationMetadata + additionalProperties = licenseTypeListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseTypeListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: LicenseTypeListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPageResponse = + LicenseTypeListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeListPageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt new file mode 100644 index 000000000..f76037c25 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects + +/** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ +class LicenseTypeListParams +private constructor( + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(): String? = cursor + + /** The number of items to fetch. Defaults to 20. */ + fun limit(): Long? = limit + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): LicenseTypeListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseTypeListParams]. */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseTypeListParams: LicenseTypeListParams) = apply { + cursor = licenseTypeListParams.cursor + limit = licenseTypeListParams.limit + additionalHeaders = licenseTypeListParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeListParams.additionalQueryParams.toBuilder() + } + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** The number of items to fetch. Defaults to 20. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseTypeListParams = + LicenseTypeListParams( + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt new file mode 100644 index 000000000..30f81c12d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseTypeListResponse: LicenseTypeListResponse) = apply { + id = licenseTypeListResponse.id + groupingKey = licenseTypeListResponse.groupingKey + name = licenseTypeListResponse.name + additionalProperties = licenseTypeListResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListResponse = + LicenseTypeListResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeListResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeListResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt new file mode 100644 index 000000000..04af62357 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects + +/** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ +class LicenseTypeRetrieveParams +private constructor( + private val licenseTypeId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseTypeId(): String? = licenseTypeId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): LicenseTypeRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeRetrieveParams]. + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeRetrieveParams]. */ + class Builder internal constructor() { + + private var licenseTypeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseTypeRetrieveParams: LicenseTypeRetrieveParams) = apply { + licenseTypeId = licenseTypeRetrieveParams.licenseTypeId + additionalHeaders = licenseTypeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeRetrieveParams.additionalQueryParams.toBuilder() + } + + fun licenseTypeId(licenseTypeId: String?) = apply { this.licenseTypeId = licenseTypeId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseTypeRetrieveParams = + LicenseTypeRetrieveParams( + licenseTypeId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseTypeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeRetrieveParams && + licenseTypeId == other.licenseTypeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(licenseTypeId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeRetrieveParams{licenseTypeId=$licenseTypeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt new file mode 100644 index 000000000..73e8b78fd --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeRetrieveResponse]. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseTypeRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseTypeRetrieveResponse: LicenseTypeRetrieveResponse) = apply { + id = licenseTypeRetrieveResponse.id + groupingKey = licenseTypeRetrieveResponse.groupingKey + name = licenseTypeRetrieveResponse.name + additionalProperties = licenseTypeRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (id.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (name.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeRetrieveResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeRetrieveResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt new file mode 100644 index 000000000..0ca14bbd7 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects + +/** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseUsageGetAllUsageParams +private constructor( + private val licenseTypeId: String, + private val subscriptionId: String, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(): String = licenseTypeId + + /** The subscription ID to get license usage for. */ + fun subscriptionId(): String = subscriptionId + + /** Pagination cursor from a previous request. */ + fun cursor(): String? = cursor + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): LocalDate? = endDate + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): List? = groupBy + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Long? = limit + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): LocalDate? = startDate + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseUsageGetAllUsageParams]. + * + * The following fields are required: + * ```kotlin + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetAllUsageParams]. */ + class Builder internal constructor() { + + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseUsageGetAllUsageParams: LicenseUsageGetAllUsageParams) = apply { + licenseTypeId = licenseUsageGetAllUsageParams.licenseTypeId + subscriptionId = licenseUsageGetAllUsageParams.subscriptionId + cursor = licenseUsageGetAllUsageParams.cursor + endDate = licenseUsageGetAllUsageParams.endDate + groupBy = licenseUsageGetAllUsageParams.groupBy?.toMutableList() + limit = licenseUsageGetAllUsageParams.limit + startDate = licenseUsageGetAllUsageParams.startDate + additionalHeaders = licenseUsageGetAllUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseUsageGetAllUsageParams.additionalQueryParams.toBuilder() + } + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The subscription ID to get license usage for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseUsageGetAllUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetAllUsageParams = + LicenseUsageGetAllUsageParams( + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetAllUsageParams && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + licenseTypeId, + subscriptionId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseUsageGetAllUsageParams{licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt new file mode 100644 index 000000000..68ae99916 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt @@ -0,0 +1,932 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects + +class LicenseUsageGetAllUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseUsageGetAllUsageResponse]. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetAllUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseUsageGetAllUsageResponse: LicenseUsageGetAllUsageResponse) = + apply { + data = licenseUsageGetAllUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseUsageGetAllUsageResponse.paginationMetadata + additionalProperties = + licenseUsageGetAllUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseUsageGetAllUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseUsageGetAllUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Double? = + allocationEligibleCredits.getNullable("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): String? = externalLicenseId.getNullable("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): String? = licenseId.getNullable("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Double? = sharedPoolCredits.getNullable("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```kotlin + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocatedCredits.asKnown() == null) 0 else 1) + + (if (consumedCredits.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (pricingUnit.asKnown() == null) 0 else 1) + + (if (remainingCredits.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + (if (allocationEligibleCredits.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseId.asKnown() == null) 0 else 1) + + (if (sharedPoolCredits.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetAllUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseUsageGetAllUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt new file mode 100644 index 000000000..239e9af3a --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt @@ -0,0 +1,299 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects + +/** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseUsageGetUsageParams +private constructor( + private val licenseId: String?, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): String? = licenseId + + /** Pagination cursor from a previous request. */ + fun cursor(): String? = cursor + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): LocalDate? = endDate + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): List? = groupBy + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Long? = limit + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): LocalDate? = startDate + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + fun none(): LicenseUsageGetUsageParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [LicenseUsageGetUsageParams]. + */ + fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetUsageParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + internal fun from(licenseUsageGetUsageParams: LicenseUsageGetUsageParams) = apply { + licenseId = licenseUsageGetUsageParams.licenseId + cursor = licenseUsageGetUsageParams.cursor + endDate = licenseUsageGetUsageParams.endDate + groupBy = licenseUsageGetUsageParams.groupBy?.toMutableList() + limit = licenseUsageGetUsageParams.limit + startDate = licenseUsageGetUsageParams.startDate + additionalHeaders = licenseUsageGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseUsageGetUsageParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseUsageGetUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseUsageGetUsageParams = + LicenseUsageGetUsageParams( + licenseId, + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetUsageParams && + licenseId == other.licenseId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + licenseId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseUsageGetUsageParams{licenseId=$licenseId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt new file mode 100644 index 000000000..ca6e129a1 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt @@ -0,0 +1,929 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects + +class LicenseUsageGetUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseUsageGetUsageResponse]. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(licenseUsageGetUsageResponse: LicenseUsageGetUsageResponse) = apply { + data = licenseUsageGetUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseUsageGetUsageResponse.paginationMetadata + additionalProperties = licenseUsageGetUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseUsageGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseUsageGetUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (data.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage period. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Double? = + allocationEligibleCredits.getNullable("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): String? = externalLicenseId.getNullable("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): String? = licenseId.getNullable("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Double? = sharedPoolCredits.getNullable("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```kotlin + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocatedCredits.asKnown() == null) 0 else 1) + + (if (consumedCredits.asKnown() == null) 0 else 1) + + (if (endDate.asKnown() == null) 0 else 1) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (if (pricingUnit.asKnown() == null) 0 else 1) + + (if (remainingCredits.asKnown() == null) 0 else 1) + + (if (startDate.asKnown() == null) 0 else 1) + + (if (subscriptionId.asKnown() == null) 0 else 1) + + (if (allocationEligibleCredits.asKnown() == null) 0 else 1) + + (if (externalLicenseId.asKnown() == null) 0 else 1) + + (if (licenseId.asKnown() == null) 0 else 1) + + (if (sharedPoolCredits.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseUsageGetUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt index ec43fd562..727b1bd04 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt @@ -8,6 +8,8 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponse import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse @@ -76,6 +78,41 @@ interface CreditBlockServiceAsync { suspend fun delete(blockId: String, requestOptions: RequestOptions) = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + /** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added or allocated from a + * subscription), this endpoint returns the invoices that were created to charge the customer + * for the credit block. For credit blocks with payment schedules spanning multiple periods + * (e.g., monthly payments over 12 months), multiple invoices will be returned. + * + * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices + * list is returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future + * releases. Please contact support before building production integrations against this + * endpoint.** + */ + suspend fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + suspend fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse + + /** @see listInvoices */ + suspend fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) + /** * A view of [CreditBlockServiceAsync] that provides access to raw HTTP responses for each * method. @@ -140,5 +177,32 @@ interface CreditBlockServiceAsync { @MustBeClosed suspend fun delete(blockId: String, requestOptions: RequestOptions): HttpResponse = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is + * otherwise the same as [CreditBlockServiceAsync.listInvoices]. + */ + @MustBeClosed + suspend fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + @MustBeClosed + suspend fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listInvoices */ + @MustBeClosed + suspend fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt index 9ce641103..d6fdc1b93 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt @@ -18,6 +18,8 @@ import com.withorb.api.core.http.json import com.withorb.api.core.http.parseable import com.withorb.api.core.prepareAsync import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse @@ -45,6 +47,13 @@ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions withRawResponse().delete(params, requestOptions) } + override suspend fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + // get /credit_blocks/{block_id}/invoices + withRawResponse().listInvoices(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockServiceAsync.WithRawResponse { @@ -111,5 +120,35 @@ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions response.use { deleteHandler.handle(it) } } } + + private val listInvoicesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credit_blocks", params._pathParam(0), "invoices") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listInvoicesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index ac4ff0c6e..86bafe2f2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -14,6 +14,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceListSummaryPageAsync @@ -160,6 +162,36 @@ interface InvoiceServiceAsync { suspend fun issue(invoiceId: String, requestOptions: RequestOptions): Invoice = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * 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). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice + * summary without any line item details. + */ + suspend fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + suspend fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse + + /** @see issueSummary */ + suspend fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * This is a lighter-weight endpoint that returns a list of all * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. @@ -397,6 +429,33 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions, ): HttpResponseFor = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is + * otherwise the same as [InvoiceServiceAsync.issueSummary]. + */ + @MustBeClosed + suspend fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + @MustBeClosed + suspend fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see issueSummary */ + @MustBeClosed + suspend fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the same as * [InvoiceServiceAsync.listSummary]. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt index b9faf6a75..242b0fbd2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt @@ -24,6 +24,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListPageResponse import com.withorb.api.models.InvoiceListParams @@ -97,6 +99,13 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl // post /invoices/{invoice_id}/issue withRawResponse().issue(params, requestOptions).parse() + override suspend fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + // post /invoices/summary/{invoice_id}/issue + withRawResponse().issueSummary(params, requestOptions).parse() + override suspend fun listSummary( params: InvoiceListSummaryParams, requestOptions: RequestOptions, @@ -338,6 +347,37 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val issueSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("invoices", "summary", params._pathParam(0), "issue") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { issueSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listSummaryHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt new file mode 100644 index 000000000..c6343fd69 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPageAsync +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsync +import com.withorb.api.services.async.licenses.UsageServiceAsync + +interface LicenseServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseServiceAsync + + fun externalLicenses(): ExternalLicenseServiceAsync + + fun usage(): UsageServiceAsync + + /** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified + * date in the customer's timezone. Otherwise, the activation time will default to the **start** + * of the current day in the customer's timezone. + */ + suspend fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseCreateResponse + + /** This endpoint is used to fetch a license given an identifier. */ + suspend fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + suspend fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse + + /** @see retrieve */ + suspend fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): LicenseRetrieveResponse = retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** This endpoint returns a list of all licenses for a subscription. */ + suspend fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseListPageAsync + + /** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** + * of the current day in the customer's timezone. + */ + suspend fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + suspend fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse + + /** @see deactivate */ + suspend fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): LicenseDeactivateResponse = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** This endpoint is used to fetch a license given an external license identifier. */ + suspend fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + suspend fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse + + /** + * A view of [LicenseServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseServiceAsync.WithRawResponse + + fun externalLicenses(): ExternalLicenseServiceAsync.WithRawResponse + + fun usage(): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /licenses`, but is otherwise the same as + * [LicenseServiceAsync.create]. + */ + @MustBeClosed + suspend fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the same + * as [LicenseServiceAsync.retrieve]. + */ + @MustBeClosed + suspend fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + suspend fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + suspend fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /licenses`, but is otherwise the same as + * [LicenseServiceAsync.list]. + */ + @MustBeClosed + suspend fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is + * otherwise the same as [LicenseServiceAsync.deactivate]. + */ + @MustBeClosed + suspend fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + @MustBeClosed + suspend fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see deactivate */ + @MustBeClosed + suspend fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /licenses/external_license_id/{external_license_id}`, but is otherwise the same as + * [LicenseServiceAsync.retrieveByExternalId]. + */ + @MustBeClosed + suspend fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + @MustBeClosed + suspend fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt new file mode 100644 index 000000000..af8787d4d --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPageAsync +import com.withorb.api.models.LicenseListPageResponse +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsync +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsyncImpl +import com.withorb.api.services.async.licenses.UsageServiceAsync +import com.withorb.api.services.async.licenses.UsageServiceAsyncImpl + +class LicenseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseServiceAsync { + + private val withRawResponse: LicenseServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val externalLicenses: ExternalLicenseServiceAsync by lazy { + ExternalLicenseServiceAsyncImpl(clientOptions) + } + + private val usage: UsageServiceAsync by lazy { UsageServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): LicenseServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseServiceAsync = + LicenseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + + override fun externalLicenses(): ExternalLicenseServiceAsync = externalLicenses + + override fun usage(): UsageServiceAsync = usage + + override suspend fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): LicenseCreateResponse = + // post /licenses + withRawResponse().create(params, requestOptions).parse() + + override suspend fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): LicenseRetrieveResponse = + // get /licenses/{license_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override suspend fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): LicenseListPageAsync = + // get /licenses + withRawResponse().list(params, requestOptions).parse() + + override suspend fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): LicenseDeactivateResponse = + // post /licenses/{license_id}/deactivate + withRawResponse().deactivate(params, requestOptions).parse() + + override suspend fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): LicenseRetrieveByExternalIdResponse = + // get /licenses/external_license_id/{external_license_id} + withRawResponse().retrieveByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val externalLicenses: ExternalLicenseServiceAsync.WithRawResponse by lazy { + ExternalLicenseServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val usage: UsageServiceAsync.WithRawResponse by lazy { + UsageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseServiceAsync.WithRawResponse = + LicenseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + override fun externalLicenses(): ExternalLicenseServiceAsync.WithRawResponse = + externalLicenses + + override fun usage(): UsageServiceAsync.WithRawResponse = usage + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseListPageAsync.builder() + .service(LicenseServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deactivateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "deactivate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deactivateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_license_id", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt new file mode 100644 index 000000000..e982d9523 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPageAsync +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse + +interface LicenseTypeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseTypeServiceAsync + + /** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + suspend fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeCreateResponse + + /** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ + suspend fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + suspend fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse + + /** @see retrieve */ + suspend fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + suspend fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeListPageAsync + + /** @see list */ + suspend fun list(requestOptions: RequestOptions): LicenseTypeListPageAsync = + list(LicenseTypeListParams.none(), requestOptions) + + /** + * A view of [LicenseTypeServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseTypeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /license_types`, but is otherwise the same as + * [LicenseTypeServiceAsync.create]. + */ + @MustBeClosed + suspend fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise + * the same as [LicenseTypeServiceAsync.retrieve]. + */ + @MustBeClosed + suspend fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + suspend fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + suspend fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /license_types`, but is otherwise the same as + * [LicenseTypeServiceAsync.list]. + */ + @MustBeClosed + suspend fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + suspend fun list( + requestOptions: RequestOptions + ): HttpResponseFor = + list(LicenseTypeListParams.none(), requestOptions) + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt new file mode 100644 index 000000000..d51f6d9c5 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPageAsync +import com.withorb.api.models.LicenseTypeListPageResponse +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse + +class LicenseTypeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeServiceAsync { + + private val withRawResponse: LicenseTypeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LicenseTypeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseTypeServiceAsync = + LicenseTypeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + + override suspend fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): LicenseTypeCreateResponse = + // post /license_types + withRawResponse().create(params, requestOptions).parse() + + override suspend fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + // get /license_types/{license_type_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override suspend fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): LicenseTypeListPageAsync = + // get /license_types + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseTypeServiceAsync.WithRawResponse = + LicenseTypeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseTypeId", params.licenseTypeId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseTypeListPageAsync.builder() + .service(LicenseTypeServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt new file mode 100644 index 000000000..a444e6d10 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse + +interface ExternalLicenseServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): ExternalLicenseServiceAsync + + /** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ + suspend fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse = + getUsage(params.toBuilder().externalLicenseId(externalLicenseId).build(), requestOptions) + + /** @see getUsage */ + suspend fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse + + /** + * A view of [ExternalLicenseServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): ExternalLicenseServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the same as + * [ExternalLicenseServiceAsync.getUsage]. + */ + @MustBeClosed + suspend fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see getUsage */ + @MustBeClosed + suspend fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt new file mode 100644 index 000000000..b16945bc8 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse + +class ExternalLicenseServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ExternalLicenseServiceAsync { + + private val withRawResponse: ExternalLicenseServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExternalLicenseServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): ExternalLicenseServiceAsync = + ExternalLicenseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + + override suspend fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): LicenseExternalLicenseGetUsageResponse = + // get /licenses/external_licenses/{external_license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): ExternalLicenseServiceAsync.WithRawResponse = + ExternalLicenseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_licenses", params._pathParam(0), "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt new file mode 100644 index 000000000..622da9f1e --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse + +interface UsageServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): UsageServiceAsync + + /** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ + suspend fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetAllUsageResponse + + /** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ + suspend fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + suspend fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse + + /** @see getUsage */ + suspend fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): LicenseUsageGetUsageResponse = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + + /** A view of [UsageServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the same as + * [UsageServiceAsync.getAllUsage]. + */ + @MustBeClosed + suspend fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + * same as [UsageServiceAsync.getUsage]. + */ + @MustBeClosed + suspend fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + @MustBeClosed + suspend fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getUsage */ + @MustBeClosed + suspend fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt new file mode 100644 index 000000000..2e190cffa --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse + +class UsageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync { + + private val withRawResponse: UsageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): UsageServiceAsync = + UsageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + + override suspend fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetAllUsageResponse = + // get /licenses/usage + withRawResponse().getAllUsage(params, requestOptions).parse() + + override suspend fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetUsageResponse = + // get /licenses/{license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): UsageServiceAsync.WithRawResponse = + UsageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + private val getAllUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getAllUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override suspend fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.executeAsync(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt index d91d92886..440db6477 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt @@ -8,6 +8,8 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponse import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse @@ -73,6 +75,41 @@ interface CreditBlockService { fun delete(blockId: String, requestOptions: RequestOptions) = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + /** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added or allocated from a + * subscription), this endpoint returns the invoices that were created to charge the customer + * for the credit block. For credit blocks with payment schedules spanning multiple periods + * (e.g., monthly payments over 12 months), multiple invoices will be returned. + * + * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices + * list is returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future + * releases. Please contact support before building production integrations against this + * endpoint.** + */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) + /** * A view of [CreditBlockService] that provides access to raw HTTP responses for each method. */ @@ -136,5 +173,32 @@ interface CreditBlockService { @MustBeClosed fun delete(blockId: String, requestOptions: RequestOptions): HttpResponse = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is + * otherwise the same as [CreditBlockService.listInvoices]. + */ + @MustBeClosed + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt index 942eda74f..f1d921d7f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt @@ -18,6 +18,8 @@ import com.withorb.api.core.http.json import com.withorb.api.core.http.parseable import com.withorb.api.core.prepare import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse @@ -45,6 +47,13 @@ class CreditBlockServiceImpl internal constructor(private val clientOptions: Cli withRawResponse().delete(params, requestOptions) } + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + // get /credit_blocks/{block_id}/invoices + withRawResponse().listInvoices(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockService.WithRawResponse { @@ -111,5 +120,35 @@ class CreditBlockServiceImpl internal constructor(private val clientOptions: Cli response.use { deleteHandler.handle(it) } } } + + private val listInvoicesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credit_blocks", params._pathParam(0), "invoices") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listInvoicesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index 726f9eb16..c85bc39fb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -14,6 +14,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceListSummaryPage @@ -160,6 +162,36 @@ interface InvoiceService { fun issue(invoiceId: String, requestOptions: RequestOptions): Invoice = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * 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). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice + * summary without any line item details. + */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * This is a lighter-weight endpoint that returns a list of all * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. @@ -387,6 +419,33 @@ interface InvoiceService { fun issue(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is + * otherwise the same as [InvoiceService.issueSummary]. + */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the same as * [InvoiceService.listSummary]. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt index b63cf658d..396800250 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt @@ -24,6 +24,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListPageResponse import com.withorb.api.models.InvoiceListParams @@ -82,6 +84,13 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO // post /invoices/{invoice_id}/issue withRawResponse().issue(params, requestOptions).parse() + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + // post /invoices/summary/{invoice_id}/issue + withRawResponse().issueSummary(params, requestOptions).parse() + override fun listSummary( params: InvoiceListSummaryParams, requestOptions: RequestOptions, @@ -320,6 +329,37 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO } } + private val issueSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("invoices", "summary", params._pathParam(0), "issue") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { issueSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listSummaryHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt new file mode 100644 index 000000000..4e5952911 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPage +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.blocking.licenses.ExternalLicenseService +import com.withorb.api.services.blocking.licenses.UsageService + +interface LicenseService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseService + + fun externalLicenses(): ExternalLicenseService + + fun usage(): UsageService + + /** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified + * date in the customer's timezone. Otherwise, the activation time will default to the **start** + * of the current day in the customer's timezone. + */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseCreateResponse + + /** This endpoint is used to fetch a license given an identifier. */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse + + /** @see retrieve */ + fun retrieve(licenseId: String, requestOptions: RequestOptions): LicenseRetrieveResponse = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** This endpoint returns a list of all licenses for a subscription. */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseListPage + + /** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** + * of the current day in the customer's timezone. + */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse + + /** @see deactivate */ + fun deactivate(licenseId: String, requestOptions: RequestOptions): LicenseDeactivateResponse = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** This endpoint is used to fetch a license given an external license identifier. */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse + + /** A view of [LicenseService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseService.WithRawResponse + + fun externalLicenses(): ExternalLicenseService.WithRawResponse + + fun usage(): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /licenses`, but is otherwise the same as + * [LicenseService.create]. + */ + @MustBeClosed + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the same + * as [LicenseService.retrieve]. + */ + @MustBeClosed + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /licenses`, but is otherwise the same as + * [LicenseService.list]. + */ + @MustBeClosed + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is + * otherwise the same as [LicenseService.deactivate]. + */ + @MustBeClosed + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /licenses/external_license_id/{external_license_id}`, but is otherwise the same as + * [LicenseService.retrieveByExternalId]. + */ + @MustBeClosed + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt new file mode 100644 index 000000000..99623b959 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPage +import com.withorb.api.models.LicenseListPageResponse +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.blocking.licenses.ExternalLicenseService +import com.withorb.api.services.blocking.licenses.ExternalLicenseServiceImpl +import com.withorb.api.services.blocking.licenses.UsageService +import com.withorb.api.services.blocking.licenses.UsageServiceImpl + +class LicenseServiceImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseService { + + private val withRawResponse: LicenseService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val externalLicenses: ExternalLicenseService by lazy { + ExternalLicenseServiceImpl(clientOptions) + } + + private val usage: UsageService by lazy { UsageServiceImpl(clientOptions) } + + override fun withRawResponse(): LicenseService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseService = + LicenseServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + + override fun externalLicenses(): ExternalLicenseService = externalLicenses + + override fun usage(): UsageService = usage + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): LicenseCreateResponse = + // post /licenses + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): LicenseRetrieveResponse = + // get /licenses/{license_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: LicenseListParams, requestOptions: RequestOptions): LicenseListPage = + // get /licenses + withRawResponse().list(params, requestOptions).parse() + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): LicenseDeactivateResponse = + // post /licenses/{license_id}/deactivate + withRawResponse().deactivate(params, requestOptions).parse() + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): LicenseRetrieveByExternalIdResponse = + // get /licenses/external_license_id/{external_license_id} + withRawResponse().retrieveByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val externalLicenses: ExternalLicenseService.WithRawResponse by lazy { + ExternalLicenseServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val usage: UsageService.WithRawResponse by lazy { + UsageServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseService.WithRawResponse = + LicenseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + override fun externalLicenses(): ExternalLicenseService.WithRawResponse = externalLicenses + + override fun usage(): UsageService.WithRawResponse = usage + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseListPage.builder() + .service(LicenseServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deactivateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "deactivate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deactivateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_license_id", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt new file mode 100644 index 000000000..82097a370 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPage +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse + +interface LicenseTypeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseTypeService + + /** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeCreateResponse + + /** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeListPage + + /** @see list */ + fun list(requestOptions: RequestOptions): LicenseTypeListPage = + list(LicenseTypeListParams.none(), requestOptions) + + /** + * A view of [LicenseTypeService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseTypeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /license_types`, but is otherwise the same as + * [LicenseTypeService.create]. + */ + @MustBeClosed + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise + * the same as [LicenseTypeService.retrieve]. + */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /license_types`, but is otherwise the same as + * [LicenseTypeService.list]. + */ + @MustBeClosed + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(LicenseTypeListParams.none(), requestOptions) + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt new file mode 100644 index 000000000..6646170a6 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPage +import com.withorb.api.models.LicenseTypeListPageResponse +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse + +class LicenseTypeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeService { + + private val withRawResponse: LicenseTypeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LicenseTypeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): LicenseTypeService = + LicenseTypeServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): LicenseTypeCreateResponse = + // post /license_types + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + // get /license_types/{license_type_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): LicenseTypeListPage = + // get /license_types + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): LicenseTypeService.WithRawResponse = + LicenseTypeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseTypeId", params.licenseTypeId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseTypeListPage.builder() + .service(LicenseTypeServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt new file mode 100644 index 000000000..3b9c8b95a --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse + +interface ExternalLicenseService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): ExternalLicenseService + + /** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse = + getUsage(params.toBuilder().externalLicenseId(externalLicenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse + + /** + * A view of [ExternalLicenseService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): ExternalLicenseService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the same as + * [ExternalLicenseService.getUsage]. + */ + @MustBeClosed + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt new file mode 100644 index 000000000..4d95a0a2b --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse + +class ExternalLicenseServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseService { + + private val withRawResponse: ExternalLicenseService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExternalLicenseService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): ExternalLicenseService = + ExternalLicenseServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): LicenseExternalLicenseGetUsageResponse = + // get /licenses/external_licenses/{external_license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): ExternalLicenseService.WithRawResponse = + ExternalLicenseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_licenses", params._pathParam(0), "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt new file mode 100644 index 000000000..2d3d90f65 --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse + +interface UsageService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): UsageService + + /** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetAllUsageResponse + + /** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse + + /** @see getUsage */ + fun getUsage(licenseId: String, requestOptions: RequestOptions): LicenseUsageGetUsageResponse = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + + /** A view of [UsageService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: (ClientOptions.Builder) -> Unit): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the same as + * [UsageService.getAllUsage]. + */ + @MustBeClosed + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + * same as [UsageService.getUsage]. + */ + @MustBeClosed + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + } +} diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt new file mode 100644 index 000000000..3ad70f3cb --- /dev/null +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse + +class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService { + + private val withRawResponse: UsageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): UsageService = + UsageServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetAllUsageResponse = + // get /licenses/usage + withRawResponse().getAllUsage(params, requestOptions).parse() + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetUsageResponse = + // get /licenses/{license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: (ClientOptions.Builder) -> Unit + ): UsageService.WithRawResponse = + UsageServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + + private val getAllUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getAllUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt new file mode 100644 index 000000000..a25129148 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditBlockListInvoicesParamsTest { + + @Test + fun create() { + CreditBlockListInvoicesParams.builder().blockId("block_id").build() + } + + @Test + fun pathParams() { + val params = CreditBlockListInvoicesParams.builder().blockId("block_id").build() + + assertThat(params._pathParam(0)).isEqualTo("block_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt new file mode 100644 index 000000000..6f30c53ee --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditBlockListInvoicesResponseTest { + + @Test + fun create() { + val creditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse.builder() + .block( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + .addInvoice( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + .build() + + assertThat(creditBlockListInvoicesResponse.block()) + .isEqualTo( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + assertThat(creditBlockListInvoicesResponse.invoices()) + .containsExactly( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse.builder() + .block( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + .addInvoice( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + .build() + + val roundtrippedCreditBlockListInvoicesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditBlockListInvoicesResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditBlockListInvoicesResponse) + .isEqualTo(creditBlockListInvoicesResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt new file mode 100644 index 000000000..baa4763f0 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvoiceIssueSummaryParamsTest { + + @Test + fun create() { + InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").synchronous(true).build() + } + + @Test + fun pathParams() { + val params = InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").build() + + assertThat(params._pathParam(0)).isEqualTo("invoice_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").synchronous(true).build() + + val body = params._body() + + assertThat(body.synchronous()).isEqualTo(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").build() + + val body = params._body() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt new file mode 100644 index 000000000..a9b3b9044 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt @@ -0,0 +1,401 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvoiceIssueSummaryResponseTest { + + @Test + fun create() { + val invoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .billingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memo("memo") + .metadata( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceIssueSummaryResponse.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + assertThat(invoiceIssueSummaryResponse.id()).isEqualTo("id") + assertThat(invoiceIssueSummaryResponse.amountDue()).isEqualTo("8.00") + assertThat(invoiceIssueSummaryResponse.autoCollection()) + .isEqualTo( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.billingAddress()) + .isEqualTo( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceIssueSummaryResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + assertThat(invoiceIssueSummaryResponse.creditNotes()) + .containsExactly( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.currency()).isEqualTo("USD") + assertThat(invoiceIssueSummaryResponse.customer()) + .isEqualTo( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + assertThat(invoiceIssueSummaryResponse.customerBalanceTransactions()) + .containsExactly( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + assertThat(invoiceIssueSummaryResponse.customerTaxId()) + .isEqualTo( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + assertThat(invoiceIssueSummaryResponse.dueDate()) + .isEqualTo(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + assertThat(invoiceIssueSummaryResponse.eligibleToIssueAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.hostedInvoiceUrl()).isEqualTo("hosted_invoice_url") + assertThat(invoiceIssueSummaryResponse.invoiceDate()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + assertThat(invoiceIssueSummaryResponse.invoiceNumber()).isEqualTo("JYEFHK-00001") + assertThat(invoiceIssueSummaryResponse.invoicePdf()) + .isEqualTo("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + assertThat(invoiceIssueSummaryResponse.invoiceSource()) + .isEqualTo(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + assertThat(invoiceIssueSummaryResponse.issueFailedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.issuedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.memo()).isEqualTo("memo") + assertThat(invoiceIssueSummaryResponse.metadata()) + .isEqualTo( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.paidAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.paymentAttempts()) + .containsExactly( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + assertThat(invoiceIssueSummaryResponse.paymentFailedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.paymentStartedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.scheduledIssueAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.shippingAddress()) + .isEqualTo( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceIssueSummaryResponse.status()) + .isEqualTo(InvoiceIssueSummaryResponse.Status.ISSUED) + assertThat(invoiceIssueSummaryResponse.subscription()) + .isEqualTo(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + assertThat(invoiceIssueSummaryResponse.syncFailedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.total()).isEqualTo("8.00") + assertThat(invoiceIssueSummaryResponse.voidedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.willAutoIssue()).isEqualTo(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .billingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memo("memo") + .metadata( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceIssueSummaryResponse.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + val roundtrippedInvoiceIssueSummaryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceIssueSummaryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceIssueSummaryResponse).isEqualTo(invoiceIssueSummaryResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt new file mode 100644 index 000000000..4177c1ebd --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseCreateParamsTest { + + @Test + fun create() { + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + } + + @Test + fun body() { + val params = + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + + val body = params._body() + + assertThat(body.externalLicenseId()).isEqualTo("external_license_id") + assertThat(body.licenseTypeId()).isEqualTo("license_type_id") + assertThat(body.subscriptionId()).isEqualTo("subscription_id") + assertThat(body.endDate()).isEqualTo(LocalDate.parse("2026-01-27")) + assertThat(body.startDate()).isEqualTo(LocalDate.parse("2026-01-27")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val body = params._body() + + assertThat(body.externalLicenseId()).isEqualTo("external_license_id") + assertThat(body.licenseTypeId()).isEqualTo("license_type_id") + assertThat(body.subscriptionId()).isEqualTo("subscription_id") + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt new file mode 100644 index 000000000..6cd3190db --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseCreateResponseTest { + + @Test + fun create() { + val licenseCreateResponse = + LicenseCreateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseCreateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseCreateResponse.id()).isEqualTo("id") + assertThat(licenseCreateResponse.endDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseCreateResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseCreateResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseCreateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseCreateResponse.status()).isEqualTo(LicenseCreateResponse.Status.ACTIVE) + assertThat(licenseCreateResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseCreateResponse = + LicenseCreateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseCreateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseCreateResponse).isEqualTo(licenseCreateResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt new file mode 100644 index 000000000..d22b3fe59 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseDeactivateParamsTest { + + @Test + fun create() { + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + } + + @Test + fun pathParams() { + val params = LicenseDeactivateParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + + val body = params._body() + + assertThat(body.endDate()).isEqualTo(LocalDate.parse("2026-01-27")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LicenseDeactivateParams.builder().licenseId("license_id").build() + + val body = params._body() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt new file mode 100644 index 000000000..8d2be8387 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseDeactivateResponseTest { + + @Test + fun create() { + val licenseDeactivateResponse = + LicenseDeactivateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseDeactivateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseDeactivateResponse.id()).isEqualTo("id") + assertThat(licenseDeactivateResponse.endDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseDeactivateResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseDeactivateResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseDeactivateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseDeactivateResponse.status()) + .isEqualTo(LicenseDeactivateResponse.Status.ACTIVE) + assertThat(licenseDeactivateResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseDeactivateResponse = + LicenseDeactivateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseDeactivateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseDeactivateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseDeactivateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseDeactivateResponse).isEqualTo(licenseDeactivateResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt new file mode 100644 index 000000000..4d04e1783 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseExternalLicenseGetUsageParamsTest { + + @Test + fun create() { + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun pathParams() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("external_license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt new file mode 100644 index 000000000..80cf3d8dd --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseExternalLicenseGetUsageResponseTest { + + @Test + fun create() { + val licenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse.builder() + .addData( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseExternalLicenseGetUsageResponse.data()) + .containsExactly( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseExternalLicenseGetUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse.builder() + .addData( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseExternalLicenseGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseExternalLicenseGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseExternalLicenseGetUsageResponse) + .isEqualTo(licenseExternalLicenseGetUsageResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt new file mode 100644 index 000000000..4f9b17d8b --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListPageResponseTest { + + @Test + fun create() { + val licenseListPageResponse = + LicenseListPageResponse.builder() + .addData( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseListPageResponse.data()) + .containsExactly( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + assertThat(licenseListPageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseListPageResponse = + LicenseListPageResponse.builder() + .addData( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseListPageResponse).isEqualTo(licenseListPageResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt new file mode 100644 index 000000000..41c62d909 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListParamsTest { + + @Test + fun create() { + LicenseListParams.builder() + .subscriptionId("subscription_id") + .cursor("cursor") + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .limit(1L) + .status(LicenseListParams.Status.ACTIVE) + .build() + } + + @Test + fun queryParams() { + val params = + LicenseListParams.builder() + .subscriptionId("subscription_id") + .cursor("cursor") + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .limit(1L) + .status(LicenseListParams.Status.ACTIVE) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("external_license_id", "external_license_id") + .put("license_type_id", "license_type_id") + .put("limit", "1") + .put("status", "active") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseListParams.builder().subscriptionId("subscription_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("subscription_id", "subscription_id").build()) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt new file mode 100644 index 000000000..e624f65e4 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListResponseTest { + + @Test + fun create() { + val licenseListResponse = + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseListResponse.id()).isEqualTo("id") + assertThat(licenseListResponse.endDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseListResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseListResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseListResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseListResponse.status()).isEqualTo(LicenseListResponse.Status.ACTIVE) + assertThat(licenseListResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseListResponse = + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseListResponse).isEqualTo(licenseListResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt new file mode 100644 index 000000000..a1c636dd4 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveByExternalIdParamsTest { + + @Test + fun create() { + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + } + + @Test + fun pathParams() { + val params = + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("external_license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt new file mode 100644 index 000000000..b3f3465d8 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveByExternalIdResponseTest { + + @Test + fun create() { + val licenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseRetrieveByExternalIdResponse.id()).isEqualTo("id") + assertThat(licenseRetrieveByExternalIdResponse.endDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveByExternalIdResponse.externalLicenseId()) + .isEqualTo("external_license_id") + assertThat(licenseRetrieveByExternalIdResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseRetrieveByExternalIdResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveByExternalIdResponse.status()) + .isEqualTo(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + assertThat(licenseRetrieveByExternalIdResponse.subscriptionId()) + .isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseRetrieveByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseRetrieveByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseRetrieveByExternalIdResponse) + .isEqualTo(licenseRetrieveByExternalIdResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt new file mode 100644 index 000000000..c23771812 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveParamsTest { + + @Test + fun create() { + LicenseRetrieveParams.builder().licenseId("license_id").build() + } + + @Test + fun pathParams() { + val params = LicenseRetrieveParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt new file mode 100644 index 000000000..f88370edf --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveResponseTest { + + @Test + fun create() { + val licenseRetrieveResponse = + LicenseRetrieveResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseRetrieveResponse.id()).isEqualTo("id") + assertThat(licenseRetrieveResponse.endDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseRetrieveResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseRetrieveResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveResponse.status()) + .isEqualTo(LicenseRetrieveResponse.Status.ACTIVE) + assertThat(licenseRetrieveResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseRetrieveResponse = + LicenseRetrieveResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseRetrieveResponse).isEqualTo(licenseRetrieveResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt new file mode 100644 index 000000000..4a11b64bd --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeCreateParamsTest { + + @Test + fun create() { + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + } + + @Test + fun body() { + val params = + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + + val body = params._body() + + assertThat(body.groupingKey()).isEqualTo("grouping_key") + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt new file mode 100644 index 000000000..91b78f2bb --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeCreateResponseTest { + + @Test + fun create() { + val licenseTypeCreateResponse = + LicenseTypeCreateResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeCreateResponse.id()).isEqualTo("id") + assertThat(licenseTypeCreateResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeCreateResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeCreateResponse = + LicenseTypeCreateResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeCreateResponse).isEqualTo(licenseTypeCreateResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt new file mode 100644 index 000000000..8462e1fb3 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListPageResponseTest { + + @Test + fun create() { + val licenseTypeListPageResponse = + LicenseTypeListPageResponse.builder() + .addData( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseTypeListPageResponse.data()) + .containsExactly( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + assertThat(licenseTypeListPageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeListPageResponse = + LicenseTypeListPageResponse.builder() + .addData( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseTypeListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeListPageResponse).isEqualTo(licenseTypeListPageResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt new file mode 100644 index 000000000..92c42e709 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListParamsTest { + + @Test + fun create() { + LicenseTypeListParams.builder().cursor("cursor").limit(1L).build() + } + + @Test + fun queryParams() { + val params = LicenseTypeListParams.builder().cursor("cursor").limit(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseTypeListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt new file mode 100644 index 000000000..0c5c783eb --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListResponseTest { + + @Test + fun create() { + val licenseTypeListResponse = + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeListResponse.id()).isEqualTo("id") + assertThat(licenseTypeListResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeListResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeListResponse = + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeListResponse).isEqualTo(licenseTypeListResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt new file mode 100644 index 000000000..e1d93b327 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeRetrieveParamsTest { + + @Test + fun create() { + LicenseTypeRetrieveParams.builder().licenseTypeId("license_type_id").build() + } + + @Test + fun pathParams() { + val params = LicenseTypeRetrieveParams.builder().licenseTypeId("license_type_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_type_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt new file mode 100644 index 000000000..8e7235789 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeRetrieveResponseTest { + + @Test + fun create() { + val licenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeRetrieveResponse.id()).isEqualTo("id") + assertThat(licenseTypeRetrieveResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeRetrieveResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeRetrieveResponse).isEqualTo(licenseTypeRetrieveResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt new file mode 100644 index 000000000..d9967a76c --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetAllUsageParamsTest { + + @Test + fun create() { + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun queryParams() { + val params = + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt new file mode 100644 index 000000000..041366f38 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetAllUsageResponseTest { + + @Test + fun create() { + val licenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse.builder() + .addData( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseUsageGetAllUsageResponse.data()) + .containsExactly( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseUsageGetAllUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse.builder() + .addData( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseUsageGetAllUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseUsageGetAllUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseUsageGetAllUsageResponse) + .isEqualTo(licenseUsageGetAllUsageResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt new file mode 100644 index 000000000..b14f6766e --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetUsageParamsTest { + + @Test + fun create() { + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun pathParams() { + val params = LicenseUsageGetUsageParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseUsageGetUsageParams.builder().licenseId("license_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt new file mode 100644 index 000000000..19893d26e --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetUsageResponseTest { + + @Test + fun create() { + val licenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse.builder() + .addData( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseUsageGetUsageResponse.data()) + .containsExactly( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseUsageGetUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse.builder() + .addData( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseUsageGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseUsageGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseUsageGetUsageResponse).isEqualTo(licenseUsageGetUsageResponse) + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt index 679bc031d..1dd5b96f9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt @@ -35,4 +35,18 @@ internal class CreditBlockServiceAsyncTest { creditBlockServiceAsync.delete("block_id") } + + @Test + suspend fun listInvoices() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditBlockServiceAsync = client.creditBlocks() + + val response = creditBlockServiceAsync.listInvoices("block_id") + + response.validate() + } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 5fe06d386..6888c68dd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -9,6 +9,7 @@ import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceDeleteLineItemParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount @@ -190,6 +191,26 @@ internal class InvoiceServiceAsyncTest { invoice.validate() } + @Test + suspend fun issueSummary() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val invoiceServiceAsync = client.invoices() + + val response = + invoiceServiceAsync.issueSummary( + InvoiceIssueSummaryParams.builder() + .invoiceId("invoice_id") + .synchronous(true) + .build() + ) + + response.validate() + } + @Test suspend fun listSummary() { val client = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt new file mode 100644 index 000000000..c252797c6 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseServiceAsyncTest { + + @Test + suspend fun create() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val license = + licenseServiceAsync.create( + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + ) + + license.validate() + } + + @Test + suspend fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val license = licenseServiceAsync.retrieve("license_id") + + license.validate() + } + + @Test + suspend fun list() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val page = + licenseServiceAsync.list( + LicenseListParams.builder().subscriptionId("subscription_id").build() + ) + + page.response().validate() + } + + @Test + suspend fun deactivate() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val response = + licenseServiceAsync.deactivate( + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + ) + + response.validate() + } + + @Test + suspend fun retrieveByExternalId() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val response = + licenseServiceAsync.retrieveByExternalId( + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + ) + + response.validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt new file mode 100644 index 000000000..6817aad90 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseTypeCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseTypeServiceAsyncTest { + + @Test + suspend fun create() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val licenseType = + licenseTypeServiceAsync.create( + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + ) + + licenseType.validate() + } + + @Test + suspend fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val licenseType = licenseTypeServiceAsync.retrieve("license_type_id") + + licenseType.validate() + } + + @Test + suspend fun list() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val page = licenseTypeServiceAsync.list() + + page.response().validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt new file mode 100644 index 000000000..470739565 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExternalLicenseServiceAsyncTest { + + @Test + suspend fun getUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val externalLicenseServiceAsync = client.licenses().externalLicenses() + + val response = + externalLicenseServiceAsync.getUsage( + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt new file mode 100644 index 000000000..3fcdb8490 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceAsyncTest { + + @Test + suspend fun getAllUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageServiceAsync = client.licenses().usage() + + val response = + usageServiceAsync.getAllUsage( + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } + + @Test + suspend fun getUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageServiceAsync = client.licenses().usage() + + val response = + usageServiceAsync.getUsage( + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt index b52247712..9e7a7b279 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt @@ -35,4 +35,18 @@ internal class CreditBlockServiceTest { creditBlockService.delete("block_id") } + + @Test + fun listInvoices() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditBlockService = client.creditBlocks() + + val response = creditBlockService.listInvoices("block_id") + + response.validate() + } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 5f807906f..1483cb75b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -9,6 +9,7 @@ import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceDeleteLineItemParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount @@ -190,6 +191,26 @@ internal class InvoiceServiceTest { invoice.validate() } + @Test + fun issueSummary() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val invoiceService = client.invoices() + + val response = + invoiceService.issueSummary( + InvoiceIssueSummaryParams.builder() + .invoiceId("invoice_id") + .synchronous(true) + .build() + ) + + response.validate() + } + @Test fun listSummary() { val client = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt new file mode 100644 index 000000000..739be45b4 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseServiceTest { + + @Test + fun create() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val license = + licenseService.create( + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + ) + + license.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val license = licenseService.retrieve("license_id") + + license.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val page = + licenseService.list( + LicenseListParams.builder().subscriptionId("subscription_id").build() + ) + + page.response().validate() + } + + @Test + fun deactivate() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val response = + licenseService.deactivate( + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + ) + + response.validate() + } + + @Test + fun retrieveByExternalId() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val response = + licenseService.retrieveByExternalId( + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + ) + + response.validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt new file mode 100644 index 000000000..e86dcf903 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseTypeCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseTypeServiceTest { + + @Test + fun create() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val licenseType = + licenseTypeService.create( + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + ) + + licenseType.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val licenseType = licenseTypeService.retrieve("license_type_id") + + licenseType.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val page = licenseTypeService.list() + + page.response().validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt new file mode 100644 index 000000000..3bb995d17 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExternalLicenseServiceTest { + + @Test + fun getUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val externalLicenseService = client.licenses().externalLicenses() + + val response = + externalLicenseService.getUsage( + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt new file mode 100644 index 000000000..34ec9d205 --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceTest { + + @Test + fun getAllUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageService = client.licenses().usage() + + val response = + usageService.getAllUsage( + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } + + @Test + fun getUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageService = client.licenses().usage() + + val response = + usageService.getUsage( + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt index 89b9dcb3d..541515211 100644 --- a/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt +++ b/orb-kotlin-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -68,6 +68,8 @@ internal class ProGuardCompatibilityTest { assertThat(client.dimensionalPriceGroups()).isNotNull() assertThat(client.subscriptionChanges()).isNotNull() assertThat(client.creditBlocks()).isNotNull() + assertThat(client.licenseTypes()).isNotNull() + assertThat(client.licenses()).isNotNull() } @Test From 9c54a99fc2abd5d78d679967ddf8c48c960eeb03 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 01:22:35 +0000 Subject: [PATCH 09/52] feat(api): api update --- .stats.yml | 4 +- ...editLedgerCreateEntryByExternalIdParams.kt | 46 ++++++++++++++++++- .../CustomerCreditLedgerCreateEntryParams.kt | 46 ++++++++++++++++++- ...LedgerCreateEntryByExternalIdParamsTest.kt | 3 ++ ...stomerCreditLedgerCreateEntryParamsTest.kt | 3 ++ .../credits/LedgerServiceAsyncTest.kt | 2 + .../customers/credits/LedgerServiceTest.kt | 2 + 7 files changed, 102 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index c80eee48c..fba81f582 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c92fb451e13f157b3735f188acc8d57aa3adfbaac1683645e1ba4f432dd7a4f8.yml -openapi_spec_hash: dbcd87ecfbd3976eb3b99ec6f9fbc606 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77e112caf7b2a2c7b0248b7245b5730bc72ab0ea84ba5d0777e7d0604ae04d26.yml +openapi_spec_hash: 966568dd08f34db64ba0ebace678268a config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 25f96583e..4f2598eab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -1731,6 +1731,7 @@ private constructor( private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, + private val markAsPaid: JsonField, private val memo: JsonField, private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1751,6 +1752,9 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1765,6 +1769,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -1809,6 +1814,14 @@ private constructor( */ fun itemId(): String? = itemId.getNullable("item_id") + /** + * If true, the new credits purchase invoice will be marked as paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markAsPaid(): Boolean? = markAsPaid.getNullable("mark_as_paid") + /** * An optional memo to display on the invoice. * @@ -1877,6 +1890,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [memo]. * @@ -1937,6 +1960,7 @@ private constructor( private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -1947,6 +1971,7 @@ private constructor( customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId + markAsPaid = invoiceSettings.markAsPaid memo = invoiceSettings.memo netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -2039,6 +2064,20 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** If true, the new credits purchase invoice will be marked as paid. */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(JsonField.of(markAsPaid)) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { + this.markAsPaid = markAsPaid + } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -2136,6 +2175,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2154,6 +2194,7 @@ private constructor( customDueDate()?.validate() invoiceDate()?.validate() itemId() + markAsPaid() memo() netTerms() requireSuccessfulPayment() @@ -2179,6 +2220,7 @@ private constructor( (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + + (if (markAsPaid.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + (if (netTerms.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) @@ -2550,6 +2592,7 @@ private constructor( customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && + markAsPaid == other.markAsPaid && memo == other.memo && netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -2562,6 +2605,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2572,7 +2616,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, markAsPaid=$markAsPaid, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 2d6992629..00349f4e7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -1726,6 +1726,7 @@ private constructor( private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, + private val markAsPaid: JsonField, private val memo: JsonField, private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1746,6 +1747,9 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1760,6 +1764,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -1804,6 +1809,14 @@ private constructor( */ fun itemId(): String? = itemId.getNullable("item_id") + /** + * If true, the new credits purchase invoice will be marked as paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markAsPaid(): Boolean? = markAsPaid.getNullable("mark_as_paid") + /** * An optional memo to display on the invoice. * @@ -1872,6 +1885,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [memo]. * @@ -1932,6 +1955,7 @@ private constructor( private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -1942,6 +1966,7 @@ private constructor( customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId + markAsPaid = invoiceSettings.markAsPaid memo = invoiceSettings.memo netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -2034,6 +2059,20 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** If true, the new credits purchase invoice will be marked as paid. */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(JsonField.of(markAsPaid)) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { + this.markAsPaid = markAsPaid + } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -2131,6 +2170,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2149,6 +2189,7 @@ private constructor( customDueDate()?.validate() invoiceDate()?.validate() itemId() + markAsPaid() memo() netTerms() requireSuccessfulPayment() @@ -2174,6 +2215,7 @@ private constructor( (customDueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + + (if (markAsPaid.asKnown() == null) 0 else 1) + (if (memo.asKnown() == null) 0 else 1) + (if (netTerms.asKnown() == null) 0 else 1) + (if (requireSuccessfulPayment.asKnown() == null) 0 else 1) @@ -2545,6 +2587,7 @@ private constructor( customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && + markAsPaid == other.markAsPaid && memo == other.memo && netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -2557,6 +2600,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2567,7 +2611,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, markAsPaid=$markAsPaid, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index 8d29cb30a..1283ee12c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt @@ -47,6 +47,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -115,6 +116,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -169,6 +171,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index 0cf4b256e..6ece3389c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt @@ -41,6 +41,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -104,6 +105,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -152,6 +154,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index 3b240a991..050a8b4f9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -72,6 +72,7 @@ internal class LedgerServiceAsyncTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -141,6 +142,7 @@ internal class LedgerServiceAsyncTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index 3db03f154..ded8e622d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt @@ -72,6 +72,7 @@ internal class LedgerServiceTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -141,6 +142,7 @@ internal class LedgerServiceTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) From 7eb1e48401da793d82b5b8465fef638088411e55 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:01:06 +0000 Subject: [PATCH 10/52] chore(internal): update `TestServerExtension` comment --- .../com/withorb/api/TestServerExtension.kt | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt index 4dd94b267..97c34c8f5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt @@ -15,25 +15,12 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { } catch (e: Exception) { throw RuntimeException( """ - The test suite will not run without a mock Prism server running against your OpenAPI spec. + The test suite will not run without a mock server running against your OpenAPI spec. You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests that require the mock server. - To fix: - - 1. Install Prism (requires Node 16+): - - With npm: - $ npm install -g @stoplight/prism-cli - - With yarn: - $ yarn global add @stoplight/prism-cli - - 2. Run the mock server - - To run the server, pass in the path of your OpenAPI spec to the prism command: - $ prism mock path/to/your.openapi.yml + To fix run `./scripts/mock` in a separate terminal. """ .trimIndent(), e, From 6de031f604efd812fc895269568e4debf2b36566 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 01:23:13 +0000 Subject: [PATCH 11/52] feat(api): api update --- .stats.yml | 4 +- .../com/withorb/api/models/BillableMetric.kt | 171 ++++++++- .../api/models/PriceEvaluateMultipleParams.kt | 174 ++++++++- .../withorb/api/models/PriceEvaluateParams.kt | 199 ++++++++++- .../PriceEvaluatePreviewEventsParams.kt | 174 ++++++++- .../com/withorb/api/models/PriceInterval.kt | 160 ++++++++- .../api/models/SubscriptionCreateParams.kt | 330 +++++++++++++++++- .../SubscriptionPriceIntervalsParams.kt | 330 +++++++++++++++++- .../SubscriptionSchedulePlanChangeParams.kt | 330 +++++++++++++++++- .../withorb/api/models/BillableMetricTest.kt | 16 + .../api/models/MetricListPageResponseTest.kt | 15 + .../api/models/MutatedSubscriptionTest.kt | 15 + .../models/PriceEvaluateMultipleParamsTest.kt | 18 + .../api/models/PriceEvaluateParamsTest.kt | 17 + .../PriceEvaluatePreviewEventsParamsTest.kt | 19 + .../withorb/api/models/PriceIntervalTest.kt | 16 + .../SubscriptionChangeApplyResponseTest.kt | 15 + .../SubscriptionChangeCancelResponseTest.kt | 15 + .../SubscriptionChangeRetrieveResponseTest.kt | 15 + .../models/SubscriptionCreateParamsTest.kt | 30 ++ .../SubscriptionPriceIntervalsParamsTest.kt | 30 ++ ...ubscriptionSchedulePlanChangeParamsTest.kt | 37 ++ .../withorb/api/models/SubscriptionTest.kt | 15 + .../withorb/api/models/SubscriptionsTest.kt | 15 + .../services/async/PriceServiceAsyncTest.kt | 18 + .../async/SubscriptionServiceAsyncTest.kt | 37 ++ .../api/services/blocking/PriceServiceTest.kt | 18 + .../blocking/SubscriptionServiceTest.kt | 37 ++ 28 files changed, 2250 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index fba81f582..2fd311799 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77e112caf7b2a2c7b0248b7245b5730bc72ab0ea84ba5d0777e7d0604ae04d26.yml -openapi_spec_hash: 966568dd08f34db64ba0ebace678268a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-3c7ee3ec9931aaeeb5e015a598812cde9edc09f114adb8759ef4c2054c90f7dc.yml +openapi_spec_hash: a14720041156fe4f353449142edacf0d config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index 532508cf2..9e0512b74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -11,6 +11,7 @@ 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.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -30,6 +31,7 @@ private constructor( private val metadata: JsonField, private val name: JsonField, private val status: JsonField, + private val parameterDefinitions: JsonField>, private val additionalProperties: MutableMap, ) { @@ -43,7 +45,10 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(id, description, item, metadata, name, status, mutableMapOf()) + @JsonProperty("parameter_definitions") + @ExcludeMissing + parameterDefinitions: JsonField> = JsonMissing.of(), + ) : this(id, description, item, metadata, name, status, parameterDefinitions, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -89,6 +94,13 @@ private constructor( */ fun status(): Status = status.getRequired("status") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun parameterDefinitions(): List? = + parameterDefinitions.getNullable("parameter_definitions") + /** * Returns the raw JSON value of [id]. * @@ -131,6 +143,16 @@ private constructor( */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + /** + * Returns the raw JSON value of [parameterDefinitions]. + * + * Unlike [parameterDefinitions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parameter_definitions") + @ExcludeMissing + fun _parameterDefinitions(): JsonField> = parameterDefinitions + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -170,6 +192,7 @@ private constructor( private var metadata: JsonField? = null private var name: JsonField? = null private var status: JsonField? = null + private var parameterDefinitions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(billableMetric: BillableMetric) = apply { @@ -179,6 +202,7 @@ private constructor( metadata = billableMetric.metadata name = billableMetric.name status = billableMetric.status + parameterDefinitions = billableMetric.parameterDefinitions.map { it.toMutableList() } additionalProperties = billableMetric.additionalProperties.toMutableMap() } @@ -254,6 +278,33 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + fun parameterDefinitions(parameterDefinitions: List?) = + parameterDefinitions(JsonField.ofNullable(parameterDefinitions)) + + /** + * Sets [Builder.parameterDefinitions] to an arbitrary JSON value. + * + * You should usually call [Builder.parameterDefinitions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun parameterDefinitions(parameterDefinitions: JsonField>) = + apply { + this.parameterDefinitions = parameterDefinitions.map { it.toMutableList() } + } + + /** + * Adds a single [ParameterDefinition] to [parameterDefinitions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParameterDefinition(parameterDefinition: ParameterDefinition) = apply { + parameterDefinitions = + (parameterDefinitions ?: JsonField.of(mutableListOf())).also { + checkKnown("parameterDefinitions", it).add(parameterDefinition) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -298,6 +349,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("name", name), checkRequired("status", status), + (parameterDefinitions ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -315,6 +367,7 @@ private constructor( metadata().validate() name() status().validate() + parameterDefinitions()?.forEach { it.validate() } validated = true } @@ -337,7 +390,8 @@ private constructor( (item.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (name.asKnown() == null) 0 else 1) + - (status.asKnown()?.validity() ?: 0) + (status.asKnown()?.validity() ?: 0) + + (parameterDefinitions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) /** * User specified key-value pairs for the resource. If not present, this defaults to an empty @@ -571,6 +625,105 @@ private constructor( override fun toString() = value.toString() } + class ParameterDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ParameterDefinition]. */ + fun builder() = Builder() + } + + /** A builder for [ParameterDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(parameterDefinition: ParameterDefinition) = apply { + additionalProperties = parameterDefinition.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ParameterDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ParameterDefinition = + ParameterDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ParameterDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ParameterDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ParameterDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -583,15 +736,25 @@ private constructor( metadata == other.metadata && name == other.name && status == other.status && + parameterDefinitions == other.parameterDefinitions && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, description, item, metadata, name, status, additionalProperties) + Objects.hash( + id, + description, + item, + metadata, + name, + status, + parameterDefinitions, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "BillableMetric{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, additionalProperties=$additionalProperties}" + "BillableMetric{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, parameterDefinitions=$parameterDefinitions, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index b3b4a249e..82a178b1b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -792,6 +792,7 @@ private constructor( private val externalPriceId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val price: JsonField, private val priceId: JsonField, private val additionalProperties: MutableMap, @@ -806,9 +807,20 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, filter, groupingKeys, price, priceId, mutableMapOf()) + ) : this( + externalPriceId, + filter, + groupingKeys, + metricParameterOverrides, + price, + priceId, + mutableMapOf(), + ) /** * The external ID of a price to evaluate that exists in your Orb account. @@ -837,6 +849,16 @@ private constructor( */ fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * New floating price request body params. * @@ -880,6 +902,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [price]. * @@ -918,6 +951,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -926,6 +961,7 @@ private constructor( externalPriceId = priceEvaluation.externalPriceId filter = priceEvaluation.filter groupingKeys = priceEvaluation.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = priceEvaluation.metricParameterOverrides price = priceEvaluation.price priceId = priceEvaluation.priceId additionalProperties = priceEvaluation.additionalProperties.toMutableMap() @@ -991,6 +1027,24 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) @@ -1204,6 +1258,7 @@ private constructor( externalPriceId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, price, priceId, additionalProperties.toMutableMap(), @@ -1220,6 +1275,7 @@ private constructor( externalPriceId() filter() groupingKeys() + metricParameterOverrides()?.validate() price()?.validate() priceId() validated = true @@ -1243,9 +1299,121 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + (groupingKeys.asKnown()?.size ?: 0) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -11090,6 +11258,7 @@ private constructor( externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties @@ -11100,6 +11269,7 @@ private constructor( externalPriceId, filter, groupingKeys, + metricParameterOverrides, price, priceId, additionalProperties, @@ -11109,7 +11279,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index e0731f439..91535ae65 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -103,6 +103,15 @@ private constructor( */ fun groupingKeys(): List? = body.groupingKeys() + /** + * Optional overrides for parameterized billable metric parameters. If the metric has parameter + * definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = body.metricParameterOverrides() + /** * Returns the raw JSON value of [timeframeEnd]. * @@ -146,6 +155,15 @@ private constructor( */ fun _groupingKeys(): JsonField> = body._groupingKeys() + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _metricParameterOverrides(): JsonField = + body._metricParameterOverrides() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -298,6 +316,25 @@ private constructor( */ fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = apply { + body.metricParameterOverrides(metricParameterOverrides) + } + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { body.metricParameterOverrides(metricParameterOverrides) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -458,6 +495,7 @@ private constructor( private val externalCustomerId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val additionalProperties: MutableMap, ) { @@ -479,6 +517,9 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), ) : this( timeframeEnd, timeframeStart, @@ -486,6 +527,7 @@ private constructor( externalCustomerId, filter, groupingKeys, + metricParameterOverrides, mutableMapOf(), ) @@ -540,6 +582,16 @@ private constructor( */ fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * Returns the raw JSON value of [timeframeEnd]. * @@ -596,6 +648,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -631,6 +694,8 @@ private constructor( private var externalCustomerId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { @@ -640,6 +705,7 @@ private constructor( externalCustomerId = body.externalCustomerId filter = body.filter groupingKeys = body.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = body.metricParameterOverrides additionalProperties = body.additionalProperties.toMutableMap() } @@ -745,6 +811,24 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -785,6 +869,7 @@ private constructor( externalCustomerId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, additionalProperties.toMutableMap(), ) } @@ -802,6 +887,7 @@ private constructor( externalCustomerId() filter() groupingKeys() + metricParameterOverrides()?.validate() validated = true } @@ -825,7 +911,8 @@ private constructor( (if (customerId.asKnown() == null) 0 else 1) + (if (externalCustomerId.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + - (groupingKeys.asKnown()?.size ?: 0) + (groupingKeys.asKnown()?.size ?: 0) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -839,6 +926,7 @@ private constructor( externalCustomerId == other.externalCustomerId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && additionalProperties == other.additionalProperties } @@ -850,6 +938,7 @@ private constructor( externalCustomerId, filter, groupingKeys, + metricParameterOverrides, additionalProperties, ) } @@ -857,7 +946,113 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, customerId=$customerId, externalCustomerId=$externalCustomerId, filter=$filter, groupingKeys=$groupingKeys, additionalProperties=$additionalProperties}" + "Body{timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, customerId=$customerId, externalCustomerId=$externalCustomerId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, additionalProperties=$additionalProperties}" + } + + /** + * Optional overrides for parameterized billable metric parameters. If the metric has parameter + * definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index f0c641cdb..3af50c285 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1327,6 +1327,7 @@ private constructor( private val externalPriceId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val price: JsonField, private val priceId: JsonField, private val additionalProperties: MutableMap, @@ -1341,9 +1342,20 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, filter, groupingKeys, price, priceId, mutableMapOf()) + ) : this( + externalPriceId, + filter, + groupingKeys, + metricParameterOverrides, + price, + priceId, + mutableMapOf(), + ) /** * The external ID of a price to evaluate that exists in your Orb account. @@ -1372,6 +1384,16 @@ private constructor( */ fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * New floating price request body params. * @@ -1415,6 +1437,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [price]. * @@ -1453,6 +1486,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1461,6 +1496,7 @@ private constructor( externalPriceId = priceEvaluation.externalPriceId filter = priceEvaluation.filter groupingKeys = priceEvaluation.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = priceEvaluation.metricParameterOverrides price = priceEvaluation.price priceId = priceEvaluation.priceId additionalProperties = priceEvaluation.additionalProperties.toMutableMap() @@ -1526,6 +1562,24 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) @@ -1739,6 +1793,7 @@ private constructor( externalPriceId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, price, priceId, additionalProperties.toMutableMap(), @@ -1755,6 +1810,7 @@ private constructor( externalPriceId() filter() groupingKeys() + metricParameterOverrides()?.validate() price()?.validate() priceId() validated = true @@ -1778,9 +1834,121 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (filter.asKnown() == null) 0 else 1) + (groupingKeys.asKnown()?.size ?: 0) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -11625,6 +11793,7 @@ private constructor( externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties @@ -11635,6 +11804,7 @@ private constructor( externalPriceId, filter, groupingKeys, + metricParameterOverrides, price, priceId, additionalProperties, @@ -11644,7 +11814,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index bbde398bc..0134c57d8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -36,6 +36,7 @@ private constructor( private val price: JsonField, private val startDate: JsonField, private val usageCustomerIds: JsonField>, + private val metricParameterOverrides: JsonField, private val additionalProperties: MutableMap, ) { @@ -68,6 +69,9 @@ private constructor( @JsonProperty("usage_customer_ids") @ExcludeMissing usageCustomerIds: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), ) : this( id, billingCycleDay, @@ -80,6 +84,7 @@ private constructor( price, startDate, usageCustomerIds, + metricParameterOverrides, mutableMapOf(), ) @@ -189,6 +194,16 @@ private constructor( */ fun usageCustomerIds(): List? = usageCustomerIds.getNullable("usage_customer_ids") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, values + * are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * Returns the raw JSON value of [id]. * @@ -285,6 +300,16 @@ private constructor( @ExcludeMissing fun _usageCustomerIds(): JsonField> = usageCustomerIds + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = metricParameterOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -336,6 +361,7 @@ private constructor( private var price: JsonField? = null private var startDate: JsonField? = null private var usageCustomerIds: JsonField>? = null + private var metricParameterOverrides: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(priceInterval: PriceInterval) = apply { @@ -351,6 +377,7 @@ private constructor( price = priceInterval.price startDate = priceInterval.startDate usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } + metricParameterOverrides = priceInterval.metricParameterOverrides additionalProperties = priceInterval.additionalProperties.toMutableMap() } @@ -708,6 +735,24 @@ private constructor( } } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -764,6 +809,7 @@ private constructor( checkRequired("price", price), checkRequired("startDate", startDate), checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, + metricParameterOverrides, additionalProperties.toMutableMap(), ) } @@ -786,6 +832,7 @@ private constructor( price().validate() startDate() usageCustomerIds() + metricParameterOverrides()?.validate() validated = true } @@ -813,7 +860,114 @@ private constructor( (fixedFeeQuantityTransitions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (price.asKnown()?.validity() ?: 0) + (if (startDate.asKnown() == null) 0 else 1) + - (usageCustomerIds.asKnown()?.size ?: 0) + (usageCustomerIds.asKnown()?.size ?: 0) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, values + * are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -832,6 +986,7 @@ private constructor( price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && + metricParameterOverrides == other.metricParameterOverrides && additionalProperties == other.additionalProperties } @@ -848,6 +1003,7 @@ private constructor( price, startDate, usageCustomerIds, + metricParameterOverrides, additionalProperties, ) } @@ -855,5 +1011,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, metricParameterOverrides=$metricParameterOverrides, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 228368eac..25aec987d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4128,6 +4128,7 @@ private constructor( private val endDate: JsonField, private val externalPriceId: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, @@ -4153,6 +4154,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -4170,6 +4174,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4222,6 +4227,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4315,6 +4330,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -4385,6 +4411,8 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() @@ -4398,6 +4426,7 @@ private constructor( endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount + metricParameterOverrides = addPrice.metricParameterOverrides minimumAmount = addPrice.minimumAmount planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price @@ -4504,6 +4533,24 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4779,6 +4826,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4800,6 +4848,7 @@ private constructor( endDate() externalPriceId() maximumAmount() + metricParameterOverrides()?.validate() minimumAmount() planPhaseOrder() price()?.validate() @@ -4828,12 +4877,124 @@ private constructor( (if (endDate.asKnown() == null) 0 else 1) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -16770,6 +16931,7 @@ private constructor( endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && @@ -16785,6 +16947,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -16797,7 +16960,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } @Deprecated("deprecated") @@ -17963,6 +18126,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -17989,6 +18153,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -18001,6 +18168,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -18059,6 +18227,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -18146,6 +18324,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -18205,6 +18394,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -18217,6 +18408,7 @@ private constructor( externalPriceId = replacePrice.externalPriceId fixedPriceQuantity = replacePrice.fixedPriceQuantity maximumAmount = replacePrice.maximumAmount + metricParameterOverrides = replacePrice.metricParameterOverrides minimumAmount = replacePrice.minimumAmount price = replacePrice.price priceId = replacePrice.priceId @@ -18344,6 +18536,24 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -18587,6 +18797,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -18607,6 +18818,7 @@ private constructor( externalPriceId() fixedPriceQuantity() maximumAmount() + metricParameterOverrides()?.validate() minimumAmount() price()?.validate() priceId() @@ -18634,10 +18846,122 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -30575,6 +30899,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -30589,6 +30914,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -30599,7 +30925,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index ffecfbe05..bbfc25d62 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -995,6 +995,7 @@ private constructor( private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -1030,6 +1031,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -1048,6 +1052,7 @@ private constructor( filter, fixedFeeQuantityTransitions, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -1134,6 +1139,16 @@ private constructor( */ fun maximumAmount(): Double? = maximumAmount.getNullable("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * The minimum amount that will be billed for this price interval for a given billing * period. @@ -1254,6 +1269,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -1327,6 +1353,8 @@ private constructor( JsonField>? = null private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1344,6 +1372,7 @@ private constructor( fixedFeeQuantityTransitions = add.fixedFeeQuantityTransitions.map { it.toMutableList() } maximumAmount = add.maximumAmount + metricParameterOverrides = add.metricParameterOverrides minimumAmount = add.minimumAmount price = add.price priceId = add.priceId @@ -1604,6 +1633,24 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values (number or string). + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * The minimum amount that will be billed for this price interval for a given billing * period. @@ -1889,6 +1936,7 @@ private constructor( filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -1913,6 +1961,7 @@ private constructor( filter() fixedFeeQuantityTransitions()?.forEach { it.validate() } maximumAmount() + metricParameterOverrides()?.validate() minimumAmount() price()?.validate() priceId() @@ -1944,6 +1993,7 @@ private constructor( (if (filter.asKnown() == null) 0 else 1) + (fixedFeeQuantityTransitions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + @@ -3386,6 +3436,117 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -13236,6 +13397,7 @@ private constructor( filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -13254,6 +13416,7 @@ private constructor( filter, fixedFeeQuantityTransitions, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -13265,7 +13428,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class AddAdjustment @@ -14329,6 +14492,7 @@ private constructor( private val endDate: JsonField, private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, + private val metricParameterOverrides: JsonField, private val startDate: JsonField, private val usageCustomerIds: JsonField>, private val additionalProperties: MutableMap, @@ -14353,6 +14517,9 @@ private constructor( @ExcludeMissing fixedFeeQuantityTransitions: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), @@ -14366,6 +14533,7 @@ private constructor( endDate, filter, fixedFeeQuantityTransitions, + metricParameterOverrides, startDate, usageCustomerIds, mutableMapOf(), @@ -14427,6 +14595,16 @@ private constructor( fun fixedFeeQuantityTransitions(): List? = fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -14503,6 +14681,17 @@ private constructor( fun _fixedFeeQuantityTransitions(): JsonField> = fixedFeeQuantityTransitions + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [startDate]. * @@ -14558,6 +14747,8 @@ private constructor( private var fixedFeeQuantityTransitions: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var startDate: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14570,6 +14761,7 @@ private constructor( filter = edit.filter fixedFeeQuantityTransitions = edit.fixedFeeQuantityTransitions.map { it.toMutableList() } + metricParameterOverrides = edit.metricParameterOverrides startDate = edit.startDate usageCustomerIds = edit.usageCustomerIds.map { it.toMutableList() } additionalProperties = edit.additionalProperties.toMutableMap() @@ -14722,6 +14914,24 @@ private constructor( } } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values (number or string). + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * The updated start date of this price interval. If not specified, the start date will * not be updated. @@ -14820,6 +15030,7 @@ private constructor( endDate, filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, startDate, (usageCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -14839,6 +15050,7 @@ private constructor( endDate()?.validate() filter() fixedFeeQuantityTransitions()?.forEach { it.validate() } + metricParameterOverrides()?.validate() startDate()?.validate() usageCustomerIds() validated = true @@ -14865,6 +15077,7 @@ private constructor( (endDate.asKnown()?.validity() ?: 0) + (if (filter.asKnown() == null) 0 else 1) + (fixedFeeQuantityTransitions.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (startDate.asKnown()?.validity() ?: 0) + (usageCustomerIds.asKnown()?.size ?: 0) @@ -15269,6 +15482,117 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -15466,6 +15790,7 @@ private constructor( endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + metricParameterOverrides == other.metricParameterOverrides && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties @@ -15479,6 +15804,7 @@ private constructor( endDate, filter, fixedFeeQuantityTransitions, + metricParameterOverrides, startDate, usageCustomerIds, additionalProperties, @@ -15488,7 +15814,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, metricParameterOverrides=$metricParameterOverrides, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class EditAdjustment diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 8b368841e..2685a6a23 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -3783,6 +3783,7 @@ private constructor( private val endDate: JsonField, private val externalPriceId: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, @@ -3808,6 +3809,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -3825,6 +3829,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -3877,6 +3882,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -3970,6 +3985,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -4040,6 +4066,8 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() @@ -4053,6 +4081,7 @@ private constructor( endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount + metricParameterOverrides = addPrice.metricParameterOverrides minimumAmount = addPrice.minimumAmount planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price @@ -4159,6 +4188,24 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4434,6 +4481,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4455,6 +4503,7 @@ private constructor( endDate() externalPriceId() maximumAmount() + metricParameterOverrides()?.validate() minimumAmount() planPhaseOrder() price()?.validate() @@ -4483,12 +4532,124 @@ private constructor( (if (endDate.asKnown() == null) 0 else 1) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + (if (startDate.asKnown() == null) 0 else 1) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -16425,6 +16586,7 @@ private constructor( endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && @@ -16440,6 +16602,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -16452,7 +16615,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } /** @@ -17520,6 +17683,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -17546,6 +17710,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -17558,6 +17725,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -17616,6 +17784,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): String? = maximumAmount.getNullable("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): MetricParameterOverrides? = + metricParameterOverrides.getNullable("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -17703,6 +17881,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -17762,6 +17951,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -17774,6 +17965,7 @@ private constructor( externalPriceId = replacePrice.externalPriceId fixedPriceQuantity = replacePrice.fixedPriceQuantity maximumAmount = replacePrice.maximumAmount + metricParameterOverrides = replacePrice.metricParameterOverrides minimumAmount = replacePrice.minimumAmount price = replacePrice.price priceId = replacePrice.priceId @@ -17901,6 +18093,24 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -18144,6 +18354,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -18164,6 +18375,7 @@ private constructor( externalPriceId() fixedPriceQuantity() maximumAmount() + metricParameterOverrides()?.validate() minimumAmount() price()?.validate() priceId() @@ -18191,10 +18403,122 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (if (maximumAmount.asKnown() == null) 0 else 1) + + (metricParameterOverrides.asKnown()?.validity() ?: 0) + (if (minimumAmount.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) + (if (priceId.asKnown() == null) 0 else 1) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -30132,6 +30456,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -30146,6 +30471,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -30156,7 +30482,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt index 887177dbb..4451955f4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt @@ -45,6 +45,11 @@ internal class BillableMetricTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(billableMetric.id()).isEqualTo("id") @@ -79,6 +84,12 @@ internal class BillableMetricTest { ) assertThat(billableMetric.name()).isEqualTo("name") assertThat(billableMetric.status()).isEqualTo(BillableMetric.Status.ACTIVE) + assertThat(billableMetric.parameterDefinitions()) + .containsExactly( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -116,6 +127,11 @@ internal class BillableMetricTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedBillableMetric = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt index 4f47b1738..ab3a67472 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt @@ -47,6 +47,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .paginationMetadata( @@ -87,6 +92,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(metricListPageResponse.paginationMetadata()) @@ -130,6 +140,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .paginationMetadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 44730c0ec..76dc25aad 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -683,6 +683,11 @@ internal class MutatedSubscriptionTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -2434,6 +2439,11 @@ internal class MutatedSubscriptionTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(mutatedSubscription.redeemedCoupon()) @@ -4137,6 +4147,11 @@ internal class MutatedSubscriptionTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index fd2af83c0..1a6c867da 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -21,6 +21,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -91,6 +97,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -162,6 +174,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt index a6dc2e992..47ca46696 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,6 +19,11 @@ internal class PriceEvaluateParamsTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() } @@ -46,6 +52,11 @@ internal class PriceEvaluateParamsTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val body = params._body() @@ -59,6 +70,12 @@ internal class PriceEvaluateParamsTest { .isEqualTo("my_numeric_property > 100 AND my_other_property = 'bar'") assertThat(body.groupingKeys()) .containsExactly("case when my_event_type = 'foo' then true else false end") + assertThat(body.metricParameterOverrides()) + .isEqualTo( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index ea83e3915..91bdeeabe 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -34,6 +34,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -117,6 +123,13 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -202,6 +215,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index da55a6f0f..a417a9503 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -156,6 +156,11 @@ internal class PriceIntervalTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(priceInterval.id()).isEqualTo("id") @@ -307,6 +312,12 @@ internal class PriceIntervalTest { assertThat(priceInterval.startDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(priceInterval.usageCustomerIds()).containsExactly("string") + assertThat(priceInterval.metricParameterOverrides()) + .isEqualTo( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -455,6 +466,11 @@ internal class PriceIntervalTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedPriceInterval = diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index ae9c217a2..0a067b43c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -761,6 +761,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -2745,6 +2750,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -4693,6 +4703,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 0a12d86ad..6fb3a8301 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -761,6 +761,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -2745,6 +2750,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -4693,6 +4703,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 8f64e7cc4..1740dc31a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -761,6 +761,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -2745,6 +2750,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -4693,6 +4703,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index ad36172d3..f755f1c09 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -79,6 +79,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -244,6 +249,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -377,6 +387,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -544,6 +559,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -678,6 +698,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -849,6 +874,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 3a9a8c965..3952403d3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -52,6 +52,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -153,6 +158,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -222,6 +232,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -326,6 +341,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -381,6 +401,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -484,6 +509,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 987719acc..18c3d3918 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -81,6 +81,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -237,6 +243,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -384,6 +396,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -542,6 +560,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -677,6 +702,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -835,6 +866,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 738294d81..5d5c6056a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -683,6 +683,11 @@ internal class SubscriptionTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1362,6 +1367,11 @@ internal class SubscriptionTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(subscription.redeemedCoupon()) @@ -2056,6 +2066,11 @@ internal class SubscriptionTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index bcbbda776..b42ac5aa4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -757,6 +757,11 @@ internal class SubscriptionsTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1478,6 +1483,11 @@ internal class SubscriptionsTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -2247,6 +2257,11 @@ internal class SubscriptionsTest { ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index 3f9434b37..f940fd917 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -148,6 +148,11 @@ internal class PriceServiceAsyncTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) @@ -177,6 +182,12 @@ internal class PriceServiceAsyncTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -279,6 +290,13 @@ internal class PriceServiceAsyncTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index fc57ff8e2..f0de5abfb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -118,6 +118,11 @@ internal class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -291,6 +296,12 @@ internal class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -561,6 +572,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -671,6 +688,12 @@ internal class SubscriptionServiceAsyncTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -795,6 +818,13 @@ internal class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -959,6 +989,13 @@ internal class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index 210e40c9b..bad539a3b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -148,6 +148,11 @@ internal class PriceServiceTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) @@ -177,6 +182,12 @@ internal class PriceServiceTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -279,6 +290,13 @@ internal class PriceServiceTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 26f820f7b..96de618eb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -118,6 +118,11 @@ internal class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -291,6 +296,12 @@ internal class SubscriptionServiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -561,6 +572,12 @@ internal class SubscriptionServiceTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -671,6 +688,12 @@ internal class SubscriptionServiceTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -795,6 +818,13 @@ internal class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -959,6 +989,13 @@ internal class SubscriptionServiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() From 2435e963adf84c275057b6a2e9ede78989e59cd0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:46:25 +0000 Subject: [PATCH 12/52] chore(internal): make `OkHttp` constructor internal --- .../main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt index fe2cb08bf..6585c2b07 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt @@ -31,7 +31,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : +class OkHttpClient internal constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { From c449333d09d0b112178f42325b09fd7ff48811df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 22:02:26 +0000 Subject: [PATCH 13/52] feat(client): add more convenience service method overloads --- .../api/services/async/PriceServiceAsync.kt | 569 ++++++++++++++++++ .../api/services/blocking/PriceService.kt | 569 ++++++++++++++++++ .../services/async/PriceServiceAsyncTest.kt | 92 ++- .../api/services/blocking/PriceServiceTest.kt | 92 ++- 4 files changed, 1220 insertions(+), 102 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt index 0723f1405..ffca06049 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt @@ -6,6 +6,32 @@ import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.ClientOptions import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.NewFloatingBulkPrice +import com.withorb.api.models.NewFloatingBulkWithProrationPrice +import com.withorb.api.models.NewFloatingCumulativeGroupedBulkPrice +import com.withorb.api.models.NewFloatingGroupedAllocationPrice +import com.withorb.api.models.NewFloatingGroupedTieredPackagePrice +import com.withorb.api.models.NewFloatingGroupedTieredPrice +import com.withorb.api.models.NewFloatingGroupedWithMeteredMinimumPrice +import com.withorb.api.models.NewFloatingGroupedWithProratedMinimumPrice +import com.withorb.api.models.NewFloatingMatrixPrice +import com.withorb.api.models.NewFloatingMatrixWithAllocationPrice +import com.withorb.api.models.NewFloatingMatrixWithDisplayNamePrice +import com.withorb.api.models.NewFloatingMaxGroupTieredPackagePrice +import com.withorb.api.models.NewFloatingMinimumCompositePrice +import com.withorb.api.models.NewFloatingPackagePrice +import com.withorb.api.models.NewFloatingPackageWithAllocationPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithTieredPricingPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithUnitPricingPrice +import com.withorb.api.models.NewFloatingThresholdTotalAmountPrice +import com.withorb.api.models.NewFloatingTieredPackagePrice +import com.withorb.api.models.NewFloatingTieredPackageWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredPrice +import com.withorb.api.models.NewFloatingTieredWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredWithProrationPrice +import com.withorb.api.models.NewFloatingUnitPrice +import com.withorb.api.models.NewFloatingUnitWithPercentPrice +import com.withorb.api.models.NewFloatingUnitWithProrationPrice import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams @@ -53,6 +79,248 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see create */ + suspend fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + suspend fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + suspend fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + suspend fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + suspend fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + suspend fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + suspend fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + suspend fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), requestOptions) + + /** @see create */ + suspend fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + suspend fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + suspend fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + suspend fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + suspend fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + suspend fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + suspend fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), requestOptions) + + /** @see create */ + suspend fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), requestOptions) + + /** @see create */ + suspend fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + suspend fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + suspend fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + suspend fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + suspend fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + suspend fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + suspend fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + suspend fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), requestOptions) + + /** @see create */ + suspend fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + suspend fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing), + requestOptions, + ) + + /** @see create */ + suspend fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + suspend fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + suspend fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + suspend fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + suspend fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + suspend fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + /** * 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. @@ -214,6 +482,307 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + suspend fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + suspend fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + @MustBeClosed + suspend fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + /** * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as * [PriceServiceAsync.update]. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt index 150237621..2a18a20e1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt @@ -6,6 +6,32 @@ import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.ClientOptions import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.NewFloatingBulkPrice +import com.withorb.api.models.NewFloatingBulkWithProrationPrice +import com.withorb.api.models.NewFloatingCumulativeGroupedBulkPrice +import com.withorb.api.models.NewFloatingGroupedAllocationPrice +import com.withorb.api.models.NewFloatingGroupedTieredPackagePrice +import com.withorb.api.models.NewFloatingGroupedTieredPrice +import com.withorb.api.models.NewFloatingGroupedWithMeteredMinimumPrice +import com.withorb.api.models.NewFloatingGroupedWithProratedMinimumPrice +import com.withorb.api.models.NewFloatingMatrixPrice +import com.withorb.api.models.NewFloatingMatrixWithAllocationPrice +import com.withorb.api.models.NewFloatingMatrixWithDisplayNamePrice +import com.withorb.api.models.NewFloatingMaxGroupTieredPackagePrice +import com.withorb.api.models.NewFloatingMinimumCompositePrice +import com.withorb.api.models.NewFloatingPackagePrice +import com.withorb.api.models.NewFloatingPackageWithAllocationPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithTieredPricingPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithUnitPricingPrice +import com.withorb.api.models.NewFloatingThresholdTotalAmountPrice +import com.withorb.api.models.NewFloatingTieredPackagePrice +import com.withorb.api.models.NewFloatingTieredPackageWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredPrice +import com.withorb.api.models.NewFloatingTieredWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredWithProrationPrice +import com.withorb.api.models.NewFloatingUnitPrice +import com.withorb.api.models.NewFloatingUnitWithPercentPrice +import com.withorb.api.models.NewFloatingUnitWithProrationPrice import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams @@ -53,6 +79,248 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see create */ + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), requestOptions) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), requestOptions) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), requestOptions) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), requestOptions) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + /** * 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. @@ -212,6 +480,307 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + /** * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as * [PriceService.update]. diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index f940fd917..10d826601 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -9,7 +9,6 @@ import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewFloatingUnitPrice -import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluatePreviewEventsParams @@ -33,56 +32,47 @@ internal class PriceServiceAsyncTest { val price = priceServiceAsync.create( - PriceCreateParams.builder() - .body( - NewFloatingUnitPrice.builder() - .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingUnitPrice.ModelType.UNIT) - .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .prorated(true) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId( - "external_dimensional_price_group_id" - ) - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .licenseTypeId("license_type_id") - .metadata( - NewFloatingUnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) + NewFloatingUnitPrice.builder() + .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .modelType(NewFloatingUnitPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + NewFloatingUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index bad539a3b..38342a961 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -9,7 +9,6 @@ import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewFloatingUnitPrice -import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluatePreviewEventsParams @@ -33,56 +32,47 @@ internal class PriceServiceTest { val price = priceService.create( - PriceCreateParams.builder() - .body( - NewFloatingUnitPrice.builder() - .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingUnitPrice.ModelType.UNIT) - .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .prorated(true) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId( - "external_dimensional_price_group_id" - ) - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .licenseTypeId("license_type_id") - .metadata( - NewFloatingUnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) + NewFloatingUnitPrice.builder() + .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .modelType(NewFloatingUnitPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + NewFloatingUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() From ce4d8a2e387790b9a1faf40b8f04374a74c9110e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 23:04:01 +0000 Subject: [PATCH 14/52] feat(client): add connection pooling option --- README.md | 19 +++++++++ .../withorb/api/client/okhttp/OkHttpClient.kt | 42 +++++++++++++++++++ .../api/client/okhttp/OrbOkHttpClient.kt | 34 +++++++++++++++ .../api/client/okhttp/OrbOkHttpClientAsync.kt | 34 +++++++++++++++ 4 files changed, 129 insertions(+) diff --git a/README.md b/README.md index 4afffc4f2..a7899e974 100644 --- a/README.md +++ b/README.md @@ -408,6 +408,25 @@ val client: OrbClient = OrbOkHttpClient.builder() .build() ``` +### Connection pooling + +To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: + +```kotlin +import com.withorb.api.client.OrbClient +import com.withorb.api.client.okhttp.OrbOkHttpClient +import java.time.Duration + +val client: OrbClient = OrbOkHttpClient.builder() + .fromEnv() + // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa. + .maxIdleConnections(10) + .keepAliveDuration(Duration.ofMinutes(2)) + .build() +``` + +If both options are unset, OkHttp's default connection pool settings are used. + ### HTTPS > [!NOTE] diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt index 6585c2b07..f1a2bba05 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt @@ -14,12 +14,14 @@ import java.io.InputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.ExecutorService +import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import kotlinx.coroutines.suspendCancellableCoroutine import okhttp3.Call import okhttp3.Callback +import okhttp3.ConnectionPool import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType @@ -202,6 +204,8 @@ class OkHttpClient internal constructor(private val okHttpClient: okhttp3.OkHttp private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null @@ -213,6 +217,28 @@ class OkHttpClient internal constructor(private val okHttpClient: okhttp3.OkHttp fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + /** + * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Sets the keep-alive duration for idle connections in the underlying [ConnectionPool]. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { this.dispatcherExecutorService = dispatcherExecutorService } @@ -242,6 +268,22 @@ class OkHttpClient internal constructor(private val okHttpClient: okhttp3.OkHttp .apply { dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val maxIdleConnections = maxIdleConnections + val keepAliveDuration = keepAliveDuration + if (maxIdleConnections != null && keepAliveDuration != null) { + connectionPool( + ConnectionPool( + maxIdleConnections, + keepAliveDuration.toNanos(), + TimeUnit.NANOSECONDS, + ) + ) + } else { + check((maxIdleConnections != null) == (keepAliveDuration != null)) { + "Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set" + } + } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt index e2dfb2ce5..4798f0c14 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt @@ -45,6 +45,8 @@ class OrbOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -63,6 +65,36 @@ class OrbOkHttpClient private constructor() { fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + /** * The socket factory used to secure HTTPS connections. * @@ -294,6 +326,8 @@ class OrbOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt index 7790ccdd1..abef19f57 100644 --- a/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt +++ b/orb-kotlin-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt @@ -45,6 +45,8 @@ class OrbOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -63,6 +65,36 @@ class OrbOkHttpClientAsync private constructor() { fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + /** * The socket factory used to secure HTTPS connections. * @@ -294,6 +326,8 @@ class OrbOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) From 63f49a7d9be8e33bbdc0489310fe5ef7f5f1df44 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 01:23:01 +0000 Subject: [PATCH 15/52] feat(api): api update --- .stats.yml | 4 ++-- ...merCreditLedgerCreateEntryByExternalIdParams.kt | 13 ++++++++----- .../CustomerCreditLedgerCreateEntryParams.kt | 13 ++++++++----- .../async/customers/credits/LedgerServiceAsync.kt | 14 ++++++++++---- .../blocking/customers/credits/LedgerService.kt | 14 ++++++++++---- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2fd311799..d77036d15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-3c7ee3ec9931aaeeb5e015a598812cde9edc09f114adb8759ef4c2054c90f7dc.yml -openapi_spec_hash: a14720041156fe4f353449142edacf0d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-563cf1475c193333d5f8cab934fbf844e439db6218c5b9eccb089b5c1d797b4b.yml +openapi_spec_hash: f2b06aac248aecb248e975af25f3911c config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 4f2598eab..ed847a1a1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -76,8 +76,11 @@ import java.util.Objects * 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. Additionally, Orb also enforces invoice - * generation when a non-zero `per_unit_cost_basis` value is provided. + * cost basis with the number of credit units added. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to + * determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb @@ -1835,7 +1838,7 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured due * date calculation method. 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. Do not set this field if you want to set a custom due date. + * the invoice. You must set either `net_terms` or `custom_due_date`, but not both. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2095,8 +2098,8 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured * due date calculation method. 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. Do not set this field if you want to set a custom - * due date. + * days to pay the invoice. You must set either `net_terms` or + * `custom_due_date`, but not both. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 00349f4e7..698a9e59c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -76,8 +76,11 @@ import java.util.Objects * 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. Additionally, Orb also enforces invoice - * generation when a non-zero `per_unit_cost_basis` value is provided. + * cost basis with the number of credit units added. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to + * determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb @@ -1830,7 +1833,7 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured due * date calculation method. 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. Do not set this field if you want to set a custom due date. + * the invoice. You must set either `net_terms` or `custom_due_date`, but not both. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2090,8 +2093,8 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured * due date calculation method. 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. Do not set this field if you want to set a custom - * due date. + * days to pay the invoice. You must set either `net_terms` or + * `custom_due_date`, but not both. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index f17400dae..bfec736a0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -162,8 +162,11 @@ interface LedgerServiceAsync { * 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. Additionally, Orb also enforces invoice - * generation when a non-zero `per_unit_cost_basis` value is provided. + * the cost basis with the number of credit units added. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -275,8 +278,11 @@ interface LedgerServiceAsync { * 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. Additionally, Orb also enforces invoice - * generation when a non-zero `per_unit_cost_basis` value is provided. + * the cost basis with the number of credit units added. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index 0d74586bc..10ba63968 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -159,8 +159,11 @@ interface LedgerService { * 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. Additionally, Orb also enforces invoice - * generation when a non-zero `per_unit_cost_basis` value is provided. + * the cost basis with the number of credit units added. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -272,8 +275,11 @@ interface LedgerService { * 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. Additionally, Orb also enforces invoice - * generation when a non-zero `per_unit_cost_basis` value is provided. + * the cost basis with the number of credit units added. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. From a018be0afe3879a198d667714f0de75f2c5cdbf9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 02:23:04 +0000 Subject: [PATCH 16/52] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Item.kt | 6 +++ .../withorb/api/models/ItemUpdateParams.kt | 6 +++ ...atingScalableMatrixWithUnitPricingPrice.kt | 45 +++++++++++++++++- ...wPlanScalableMatrixWithUnitPricingPrice.kt | 45 +++++++++++++++++- ...ptionScalableMatrixWithUnitPricingPrice.kt | 45 +++++++++++++++++- .../kotlin/com/withorb/api/models/Price.kt | 47 ++++++++++++++++++- ...gScalableMatrixWithUnitPricingPriceTest.kt | 3 ++ ...nScalableMatrixWithUnitPricingPriceTest.kt | 3 ++ ...nScalableMatrixWithUnitPricingPriceTest.kt | 3 ++ .../com/withorb/api/models/PriceTest.kt | 2 + 11 files changed, 203 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index d77036d15..add28a88b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-563cf1475c193333d5f8cab934fbf844e439db6218c5b9eccb089b5c1d797b4b.yml -openapi_spec_hash: f2b06aac248aecb248e975af25f3911c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0186c0310e2a9f40302cc35f4248fca335b7ec8069502f684ba6f2fa37793033.yml +openapi_spec_hash: 4fb1d2837ad3794864a7d59d393d6ff6 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt index 92c529fe8..fedc747b8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -613,6 +613,8 @@ private constructor( val NUMERAL = of("numeral") + val STRIPE_TAX = of("stripe_tax") + fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -626,6 +628,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, } /** @@ -648,6 +651,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -672,6 +676,7 @@ private constructor( AVALARA -> Value.AVALARA ANROK -> Value.ANROK NUMERAL -> Value.NUMERAL + STRIPE_TAX -> Value.STRIPE_TAX else -> Value._UNKNOWN } @@ -694,6 +699,7 @@ private constructor( AVALARA -> Known.AVALARA ANROK -> Known.ANROK NUMERAL -> Known.NUMERAL + STRIPE_TAX -> Known.STRIPE_TAX else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index 8a68183ae..63518c75a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -793,6 +793,8 @@ private constructor( val NUMERAL = of("numeral") + val STRIPE_TAX = of("stripe_tax") + fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -806,6 +808,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, } /** @@ -828,6 +831,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -852,6 +856,7 @@ private constructor( AVALARA -> Value.AVALARA ANROK -> Value.ANROK NUMERAL -> Value.NUMERAL + STRIPE_TAX -> Value.STRIPE_TAX else -> Value._UNKNOWN } @@ -874,6 +879,7 @@ private constructor( AVALARA -> Known.AVALARA ANROK -> Known.ANROK NUMERAL -> Known.NUMERAL + STRIPE_TAX -> Known.STRIPE_TAX else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 03f76e139..ae44e0dbd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -1245,6 +1245,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1261,6 +1262,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1269,6 +1273,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1299,6 +1304,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1342,6 +1355,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1393,6 +1415,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1406,6 +1429,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1467,6 +1491,20 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1541,6 +1579,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1557,6 +1596,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1580,6 +1620,7 @@ private constructor( (if (firstDimension.asKnown() == null) 0 else 1) + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + (if (prorate.asKnown() == null) 0 else 1) + (if (secondDimension.asKnown() == null) 0 else 1) @@ -1853,6 +1894,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1863,6 +1905,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1872,7 +1915,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index 0b1d4b05a..83e2594ef 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -1288,6 +1288,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1304,6 +1305,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1312,6 +1316,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1342,6 +1347,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1385,6 +1398,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1436,6 +1458,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1449,6 +1472,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1510,6 +1534,20 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1584,6 +1622,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1600,6 +1639,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1623,6 +1663,7 @@ private constructor( (if (firstDimension.asKnown() == null) 0 else 1) + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + (if (prorate.asKnown() == null) 0 else 1) + (if (secondDimension.asKnown() == null) 0 else 1) @@ -1896,6 +1937,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1906,6 +1948,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1915,7 +1958,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index d63b87944..0809cedbe 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -1294,6 +1294,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1310,6 +1311,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1318,6 +1322,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1348,6 +1353,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1391,6 +1404,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1442,6 +1464,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1455,6 +1478,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1516,6 +1540,20 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1590,6 +1628,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1606,6 +1645,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1629,6 +1669,7 @@ private constructor( (if (firstDimension.asKnown() == null) 0 else 1) + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + (if (prorate.asKnown() == null) 0 else 1) + (if (secondDimension.asKnown() == null) 0 else 1) @@ -1902,6 +1943,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1912,6 +1954,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1921,7 +1964,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 6b2f21d63..85c4861e1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -80239,6 +80239,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -80255,6 +80256,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @@ -80265,6 +80269,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -80298,6 +80303,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -80344,6 +80357,16 @@ private constructor( @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -80396,6 +80419,7 @@ private constructor( private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -80409,6 +80433,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -80471,6 +80496,21 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -80548,6 +80588,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -80564,6 +80605,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -80587,6 +80629,7 @@ private constructor( (if (firstDimension.asKnown() == null) 0 else 1) + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + (if (prorate.asKnown() == null) 0 else 1) + (if (secondDimension.asKnown() == null) 0 else 1) @@ -80862,6 +80905,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -80872,6 +80916,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -80881,7 +80926,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index 810142c2d..e86734344 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt @@ -38,6 +38,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -106,6 +107,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -192,6 +194,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index 6d9b741e4..b83887d4a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt @@ -36,6 +36,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -103,6 +104,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -188,6 +190,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index 8c6a769fa..bee5f6327 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt @@ -37,6 +37,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -108,6 +109,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -201,6 +203,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index e0bc9668e..6f80c7fbc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -7829,6 +7829,7 @@ internal class PriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -8015,6 +8016,7 @@ internal class PriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() From 7104ce5655136a86694abe6438bb8d7df7093ff9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:44:24 +0000 Subject: [PATCH 17/52] chore: make `Properties` more resilient to `null` --- .../src/main/kotlin/com/withorb/api/core/Properties.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt index f0f63ba44..e21bb1e93 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/Properties.kt @@ -34,8 +34,9 @@ fun getOsName(): String { } } -fun getOsVersion(): String = System.getProperty("os.version", "unknown") +fun getOsVersion(): String = System.getProperty("os.version", "unknown") ?: "unknown" -fun getPackageVersion(): String = OrbClient::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = + OrbClient::class.java.`package`?.implementationVersion ?: "unknown" -fun getJavaVersion(): String = System.getProperty("java.version", "unknown") +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") ?: "unknown" From 2fb8c9eb2ca0dbbf34cf0ec88e2053dae3af1df6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 18:02:15 +0000 Subject: [PATCH 18/52] chore: drop apache dependency --- orb-kotlin-core/build.gradle.kts | 2 - .../api/core/http/HttpRequestBodies.kt | 243 ++++-- .../api/core/http/HttpRequestBodiesTest.kt | 739 ++++++++++++++++++ 3 files changed, 927 insertions(+), 57 deletions(-) create mode 100644 orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt diff --git a/orb-kotlin-core/build.gradle.kts b/orb-kotlin-core/build.gradle.kts index b86bb803d..36806e67d 100644 --- a/orb-kotlin-core/build.gradle.kts +++ b/orb-kotlin-core/build.gradle.kts @@ -27,8 +27,6 @@ dependencies { implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") - implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") - implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0") testImplementation(kotlin("test")) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt index 67ec3af78..b9610d3ee 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt @@ -6,12 +6,12 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType import com.withorb.api.core.MultipartField +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.apache.hc.core5.http.ContentType -import org.apache.hc.core5.http.HttpEntity +import java.util.UUID internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = object : HttpRequestBody { @@ -32,69 +32,202 @@ internal fun multipartFormData( jsonMapper: JsonMapper, fields: Map>, ): HttpRequestBody = - object : HttpRequestBody { - private val entity: HttpEntity by lazy { - MultipartEntityBuilder.create() - .apply { - fields.forEach { (name, field) -> - val knownValue = field.value.asKnown() - val parts = - if (knownValue is InputStream) { - // Read directly from the `InputStream` instead of reading it all - // into memory due to the `jsonMapper` serialization below. - sequenceOf(name to knownValue) - } else { - val node = jsonMapper.valueToTree(field.value) - serializePart(name, node) + MultipartBody.Builder() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + val partBody = + if (bytes is ByteArrayInputStream) { + val byteArray = bytes.readBytes() + + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(byteArray) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = byteArray.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} } + } else { + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + bytes.copyTo(outputStream) + } + + override fun contentType(): String = field.contentType - parts.forEach { (name, bytes) -> - addBinaryBody( - name, - bytes, - ContentType.parseLenient(field.contentType), - field.filename, - ) + override fun contentLength(): Long = -1L + + override fun repeatable(): Boolean = false + + override fun close() = bytes.close() + } } - } + + addPart( + MultipartBody.Part.create(name, field.filename, field.contentType, partBody) + ) } - .build() + } } + .build() + +private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().byteInputStream()) + JsonNodeType.BOOLEAN -> sequenceOf(name to node.booleanValue().toString().byteInputStream()) + JsonNodeType.NUMBER -> sequenceOf(name to node.numberValue().toString().byteInputStream()) + JsonNodeType.ARRAY -> + node.elements().asSequence().flatMap { element -> serializePart("$name[]", element) } + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = - when (node.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> emptySequence() - JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) - JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) - JsonNodeType.BOOLEAN -> - sequenceOf(name to node.booleanValue().toString().inputStream()) - JsonNodeType.NUMBER -> - sequenceOf(name to node.numberValue().toString().inputStream()) - JsonNodeType.ARRAY -> - node.elements().asSequence().flatMap { element -> - serializePart("$name[]", element) - } - JsonNodeType.OBJECT -> - node.fields().asSequence().flatMap { (key, value) -> - serializePart("$name[$key]", value) - } - JsonNodeType.POJO, - null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") +private class MultipartBody +private constructor(private val boundary: String, private val parts: List) : HttpRequestBody { + private val boundaryBytes: ByteArray = boundary.toByteArray() + private val contentType = "multipart/form-data; boundary=$boundary" + + // This must remain in sync with `contentLength`. + override fun writeTo(outputStream: OutputStream) { + parts.forEach { part -> + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(CRLF) + + outputStream.write(CONTENT_DISPOSITION) + outputStream.write(part.contentDisposition.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CONTENT_TYPE) + outputStream.write(part.contentType.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CRLF) + part.body.writeTo(outputStream) + outputStream.write(CRLF) + } + + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(DASHDASH) + outputStream.write(CRLF) + } + + override fun contentType(): String = contentType + + // This must remain in sync with `writeTo`. + override fun contentLength(): Long { + var byteCount = 0L + + parts.forEach { part -> + val contentLength = part.body.contentLength() + if (contentLength == -1L) { + return -1L } - private fun String.inputStream(): InputStream = toByteArray().inputStream() + byteCount += + DASHDASH.size + + boundaryBytes.size + + CRLF.size + + CONTENT_DISPOSITION.size + + part.contentDisposition.toByteArray().size + + CRLF.size + + CONTENT_TYPE.size + + part.contentType.toByteArray().size + + CRLF.size + + CRLF.size + + contentLength + + CRLF.size + } - override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + byteCount += DASHDASH.size + boundaryBytes.size + DASHDASH.size + CRLF.size + return byteCount + } - override fun contentType(): String = entity.contentType + override fun repeatable(): Boolean = parts.all { it.body.repeatable() } - override fun contentLength(): Long = entity.contentLength + override fun close() { + parts.forEach { it.body.close() } + } - override fun repeatable(): Boolean = entity.isRepeatable + class Builder { + private val boundary = UUID.randomUUID().toString() + private val parts: MutableList = mutableListOf() - override fun close() = entity.close() + fun addPart(part: Part) = apply { parts.add(part) } + + fun build() = MultipartBody(boundary, parts.toImmutable()) + } + + class Part + private constructor( + val contentDisposition: String, + val contentType: String, + val body: HttpRequestBody, + ) { + companion object { + fun create( + name: String, + filename: String?, + contentType: String, + body: HttpRequestBody, + ): Part { + val disposition = buildString { + append("form-data; name=") + appendQuotedString(name) + if (filename != null) { + append("; filename=") + appendQuotedString(filename) + } + } + return Part(disposition, contentType, body) + } + } + } + + companion object { + private val CRLF = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte()) + private val DASHDASH = byteArrayOf('-'.code.toByte(), '-'.code.toByte()) + private val CONTENT_DISPOSITION = "Content-Disposition: ".toByteArray() + private val CONTENT_TYPE = "Content-Type: ".toByteArray() + + private fun StringBuilder.appendQuotedString(key: String) { + append('"') + for (ch in key) { + when (ch) { + '\n' -> append("%0A") + '\r' -> append("%0D") + '"' -> append("%22") + else -> append(ch) + } + } + append('"') + } } +} diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt new file mode 100644 index 000000000..b7a705e1d --- /dev/null +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt @@ -0,0 +1,739 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core.http + +import com.withorb.api.core.MultipartField +import com.withorb.api.core.jsonMapper +import java.io.ByteArrayOutputStream +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HttpRequestBodiesTest { + + @Test + fun multipartFormData_serializesFieldWithFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "file" to + MultipartField.builder() + .value("hello") + .filename("hello.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = body.contentType()!!.substringAfter("multipart/form-data; boundary=") + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="file"; filename="hello.txt" + |Content-Type: text/plain + | + |hello + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesFieldWithoutFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("value") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStream() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "stream content".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |stream content + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesByteArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "binary" to + MultipartField.builder() + .value("abc".toByteArray()) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="binary" + |Content-Type: application/octet-stream + | + |abc + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesBooleanValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "flag" to + MultipartField.builder() + .value(true) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="flag" + |Content-Type: text/plain + | + |true + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNumberValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "count" to + MultipartField.builder().value(42).contentType("text/plain").build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="count" + |Content-Type: text/plain + | + |42 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNullValueAsNoParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "present" to + MultipartField.builder() + .value("yes") + .contentType("text/plain") + .build(), + "absent" to + MultipartField.builder() + .value(null as String?) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="present" + |Content-Type: text/plain + | + |yes + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "items" to + MultipartField.builder>() + .value(listOf("alpha", "beta", "gamma")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |alpha + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |beta + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |gamma + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesObjectAsNestedParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "meta" to + MultipartField.builder>() + .value(mapOf("key1" to "val1", "key2" to "val2")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="meta[key1]" + |Content-Type: text/plain + | + |val1 + |--$boundary + |Content-Disposition: form-data; name="meta[key2]" + |Content-Type: text/plain + | + |val2 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesMultipleFields() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "name" to + MultipartField.builder() + .value("Alice") + .contentType("text/plain") + .build(), + "age" to + MultipartField.builder().value(30).contentType("text/plain").build(), + "file" to + MultipartField.builder() + .value("file contents") + .filename("doc.txt") + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="name" + |Content-Type: text/plain + | + |Alice + |--$boundary + |Content-Disposition: form-data; name="age" + |Content-Type: text/plain + | + |30 + |--$boundary + |Content-Disposition: form-data; name="file"; filename="doc.txt" + |Content-Type: text/plain + | + |file contents + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_quotesSpecialCharactersInNameAndFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field\nname" to + MultipartField.builder() + .value("value") + .filename("file\r\"name.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field%0Aname"; filename="file%0D%22name.txt" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_writeIsRepeatable() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("repeatable") + .contentType("text/plain") + .build() + ), + ) + + val output1 = ByteArrayOutputStream() + body.writeTo(output1) + val output2 = ByteArrayOutputStream() + body.writeTo(output2) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output1.size().toLong()) + val boundary = boundary(body) + val expected = + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |repeatable + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + assertThat(output1.toString("UTF-8")).isEqualTo(expected) + assertThat(output2.toString("UTF-8")).isEqualTo(expected) + } + + @Test + fun multipartFormData_serializesByteArrayInputStream() { + // ByteArrayInputStream is specifically handled as repeatable with known content length. + val inputStream = "byte array stream".byteInputStream() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |byte array stream + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStreamWithFilename() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "file data".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "upload" to + MultipartField.builder() + .value(inputStream) + .filename("upload.bin") + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="upload"; filename="upload.bin" + |Content-Type: application/octet-stream + | + |file data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNestedArrayInObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder>>() + .value(mapOf("tags" to listOf("a", "b"))) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data[tags][]" + |Content-Type: text/plain + | + |a + |--$boundary + |Content-Disposition: form-data; name="data[tags][]" + |Content-Type: text/plain + | + |b + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_contentLengthIsUnknownWhenInputStreamPresent() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "text" to + MultipartField.builder() + .value("hello") + .contentType("text/plain") + .build(), + "stream" to + MultipartField.builder() + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the + // non-repeatable code path. + .value("data".byteInputStream().buffered()) + .contentType("application/octet-stream") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="text" + |Content-Type: text/plain + | + |hello + |--$boundary + |Content-Disposition: form-data; name="stream" + |Content-Type: application/octet-stream + | + |data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "items" to + MultipartField.builder>() + .value(emptyList()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "meta" to + MultipartField.builder>() + .value(emptyMap()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + private fun boundary(body: HttpRequestBody): String = + body.contentType()!!.substringAfter("multipart/form-data; boundary=") +} From 4e1cecf9966e60a856333a3fd94f08ffb5abe1d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:20:40 +0000 Subject: [PATCH 19/52] chore(internal): expand imports --- .../com/withorb/api/core/http/RetryingHttpClient.kt | 2 ++ .../withorb/api/core/http/RetryingHttpClientTest.kt | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index 0c35d198d..bebc6c5f9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.withorb.api.core.http import com.withorb.api.core.DefaultSleeper diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index e0b8d001c..ebe67c78b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.withorb.api.core.http -import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matching +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.resetAllScenarios +import com.github.tomakehurst.wiremock.client.WireMock.serviceUnavailable +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario From c57175fc1dc641c6d28ad1dc72cec513bc5982c2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:07:56 +0000 Subject: [PATCH 20/52] chore(docs): add missing descriptions --- .../com/withorb/api/client/OrbClient.kt | 186 ++++++++++++++++++ .../com/withorb/api/client/OrbClientAsync.kt | 186 ++++++++++++++++++ .../withorb/api/client/OrbClientAsyncImpl.kt | 186 ++++++++++++++++++ .../com/withorb/api/client/OrbClientImpl.kt | 186 ++++++++++++++++++ .../api/services/async/AlertServiceAsync.kt | 6 + .../services/async/AlertServiceAsyncImpl.kt | 6 + .../api/services/async/BetaServiceAsync.kt | 15 ++ .../services/async/BetaServiceAsyncImpl.kt | 15 ++ .../api/services/async/CouponServiceAsync.kt | 18 ++ .../services/async/CouponServiceAsyncImpl.kt | 18 ++ .../services/async/CreditBlockServiceAsync.kt | 4 + .../async/CreditBlockServiceAsyncImpl.kt | 4 + .../services/async/CreditNoteServiceAsync.kt | 4 + .../async/CreditNoteServiceAsyncImpl.kt | 4 + .../services/async/CustomerServiceAsync.kt | 98 +++++++++ .../async/CustomerServiceAsyncImpl.kt | 98 +++++++++ .../api/services/async/EventServiceAsync.kt | 25 +++ .../services/async/EventServiceAsyncImpl.kt | 25 +++ .../async/InvoiceLineItemServiceAsync.kt | 7 + .../async/InvoiceLineItemServiceAsyncImpl.kt | 7 + .../api/services/async/InvoiceServiceAsync.kt | 7 + .../services/async/InvoiceServiceAsyncImpl.kt | 7 + .../api/services/async/ItemServiceAsync.kt | 5 + .../services/async/ItemServiceAsyncImpl.kt | 5 + .../services/async/LicenseTypeServiceAsync.kt | 4 + .../async/LicenseTypeServiceAsyncImpl.kt | 4 + .../api/services/async/MetricServiceAsync.kt | 4 + .../services/async/MetricServiceAsyncImpl.kt | 4 + .../api/services/async/PlanServiceAsync.kt | 25 +++ .../services/async/PlanServiceAsyncImpl.kt | 25 +++ .../api/services/async/PriceServiceAsync.kt | 36 ++++ .../services/async/PriceServiceAsyncImpl.kt | 36 ++++ .../async/beta/ExternalPlanIdServiceAsync.kt | 5 + .../beta/ExternalPlanIdServiceAsyncImpl.kt | 5 + .../async/coupons/SubscriptionServiceAsync.kt | 6 + .../coupons/SubscriptionServiceAsyncImpl.kt | 6 + .../BalanceTransactionServiceAsync.kt | 18 ++ .../BalanceTransactionServiceAsyncImpl.kt | 18 ++ .../async/customers/CostServiceAsync.kt | 18 ++ .../async/customers/CostServiceAsyncImpl.kt | 18 ++ .../async/customers/CreditServiceAsync.kt | 20 ++ .../async/customers/CreditServiceAsyncImpl.kt | 20 ++ .../customers/credits/LedgerServiceAsync.kt | 4 + .../credits/LedgerServiceAsyncImpl.kt | 4 + .../customers/credits/TopUpServiceAsync.kt | 4 + .../credits/TopUpServiceAsyncImpl.kt | 4 + .../async/events/BackfillServiceAsync.kt | 5 + .../async/events/BackfillServiceAsyncImpl.kt | 5 + .../async/events/VolumeServiceAsync.kt | 5 + .../async/events/VolumeServiceAsyncImpl.kt | 5 + .../async/plans/ExternalPlanIdServiceAsync.kt | 5 + .../plans/ExternalPlanIdServiceAsyncImpl.kt | 5 + .../async/plans/MigrationServiceAsync.kt | 5 + .../async/plans/MigrationServiceAsyncImpl.kt | 5 + .../prices/ExternalPriceIdServiceAsync.kt | 12 ++ .../prices/ExternalPriceIdServiceAsyncImpl.kt | 12 ++ .../api/services/blocking/AlertService.kt | 6 + .../api/services/blocking/AlertServiceImpl.kt | 6 + .../api/services/blocking/BetaService.kt | 15 ++ .../api/services/blocking/BetaServiceImpl.kt | 15 ++ .../api/services/blocking/CouponService.kt | 18 ++ .../services/blocking/CouponServiceImpl.kt | 18 ++ .../services/blocking/CreditBlockService.kt | 4 + .../blocking/CreditBlockServiceImpl.kt | 4 + .../services/blocking/CreditNoteService.kt | 4 + .../blocking/CreditNoteServiceImpl.kt | 4 + .../api/services/blocking/CustomerService.kt | 98 +++++++++ .../services/blocking/CustomerServiceImpl.kt | 98 +++++++++ .../api/services/blocking/EventService.kt | 25 +++ .../api/services/blocking/EventServiceImpl.kt | 25 +++ .../blocking/InvoiceLineItemService.kt | 7 + .../blocking/InvoiceLineItemServiceImpl.kt | 7 + .../api/services/blocking/InvoiceService.kt | 7 + .../services/blocking/InvoiceServiceImpl.kt | 7 + .../api/services/blocking/ItemService.kt | 5 + .../api/services/blocking/ItemServiceImpl.kt | 5 + .../services/blocking/LicenseTypeService.kt | 4 + .../blocking/LicenseTypeServiceImpl.kt | 4 + .../api/services/blocking/MetricService.kt | 4 + .../services/blocking/MetricServiceImpl.kt | 4 + .../api/services/blocking/PlanService.kt | 25 +++ .../api/services/blocking/PlanServiceImpl.kt | 25 +++ .../api/services/blocking/PriceService.kt | 36 ++++ .../api/services/blocking/PriceServiceImpl.kt | 36 ++++ .../blocking/beta/ExternalPlanIdService.kt | 5 + .../beta/ExternalPlanIdServiceImpl.kt | 5 + .../blocking/coupons/SubscriptionService.kt | 6 + .../coupons/SubscriptionServiceImpl.kt | 6 + .../customers/BalanceTransactionService.kt | 18 ++ .../BalanceTransactionServiceImpl.kt | 18 ++ .../blocking/customers/CostService.kt | 18 ++ .../blocking/customers/CostServiceImpl.kt | 18 ++ .../blocking/customers/CreditService.kt | 20 ++ .../blocking/customers/CreditServiceImpl.kt | 20 ++ .../customers/credits/LedgerService.kt | 4 + .../customers/credits/LedgerServiceImpl.kt | 4 + .../customers/credits/TopUpService.kt | 4 + .../customers/credits/TopUpServiceImpl.kt | 4 + .../blocking/events/BackfillService.kt | 5 + .../blocking/events/BackfillServiceImpl.kt | 5 + .../services/blocking/events/VolumeService.kt | 5 + .../blocking/events/VolumeServiceImpl.kt | 5 + .../blocking/plans/ExternalPlanIdService.kt | 5 + .../plans/ExternalPlanIdServiceImpl.kt | 5 + .../blocking/plans/MigrationService.kt | 5 + .../blocking/plans/MigrationServiceImpl.kt | 5 + .../blocking/prices/ExternalPriceIdService.kt | 12 ++ .../prices/ExternalPriceIdServiceImpl.kt | 12 ++ 108 files changed, 2204 insertions(+) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt index ba2270776..0b8733add 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt @@ -62,30 +62,115 @@ interface OrbClient { fun topLevel(): TopLevelService + /** + * The [Plan](/core-concepts#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). + */ fun beta(): BetaService + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun coupons(): CouponService + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ fun creditNotes(): CreditNoteService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun customers(): CustomerService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun events(): EventService + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemService + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoices(): InvoiceService + /** + * 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. + */ fun items(): ItemService + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricService + /** + * The [Plan](/core-concepts#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). + */ fun plans(): PlanService + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceService fun subscriptions(): SubscriptionService + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertService fun dimensionalPriceGroups(): DimensionalPriceGroupService @@ -94,8 +179,16 @@ interface OrbClient { fun webhooks(): WebhookService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockService + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ fun licenseTypes(): LicenseTypeService fun licenses(): LicenseService @@ -125,38 +218,131 @@ interface OrbClient { fun topLevel(): TopLevelService.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun beta(): BetaService.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun coupons(): CouponService.WithRawResponse + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ fun creditNotes(): CreditNoteService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun customers(): CustomerService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun events(): EventService.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoices(): InvoiceService.WithRawResponse + /** + * 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. + */ fun items(): ItemService.WithRawResponse + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricService.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun plans(): PlanService.WithRawResponse + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceService.WithRawResponse fun subscriptions(): SubscriptionService.WithRawResponse + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertService.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockService.WithRawResponse + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ fun licenseTypes(): LicenseTypeService.WithRawResponse fun licenses(): LicenseService.WithRawResponse diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt index c28cafb22..a2bfabd1c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt @@ -61,38 +61,131 @@ interface OrbClientAsync { fun topLevel(): TopLevelServiceAsync + /** + * The [Plan](/core-concepts#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). + */ fun beta(): BetaServiceAsync + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun coupons(): CouponServiceAsync + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ fun creditNotes(): CreditNoteServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun customers(): CustomerServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun events(): EventServiceAsync + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemServiceAsync + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoices(): InvoiceServiceAsync + /** + * 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. + */ fun items(): ItemServiceAsync + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricServiceAsync + /** + * The [Plan](/core-concepts#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). + */ fun plans(): PlanServiceAsync + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceServiceAsync fun subscriptions(): SubscriptionServiceAsync + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertServiceAsync fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync fun subscriptionChanges(): SubscriptionChangeServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockServiceAsync + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ fun licenseTypes(): LicenseTypeServiceAsync fun licenses(): LicenseServiceAsync @@ -122,38 +215,131 @@ interface OrbClientAsync { fun topLevel(): TopLevelServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun beta(): BetaServiceAsync.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun coupons(): CouponServiceAsync.WithRawResponse + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ fun creditNotes(): CreditNoteServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun customers(): CustomerServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun events(): EventServiceAsync.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoices(): InvoiceServiceAsync.WithRawResponse + /** + * 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. + */ fun items(): ItemServiceAsync.WithRawResponse + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun plans(): PlanServiceAsync.WithRawResponse + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceServiceAsync.WithRawResponse fun subscriptions(): SubscriptionServiceAsync.WithRawResponse + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertServiceAsync.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse fun licenses(): LicenseServiceAsync.WithRawResponse diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index c1f5a400c..2104260c1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -139,30 +139,115 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun topLevel(): TopLevelServiceAsync = topLevel + /** + * The [Plan](/core-concepts#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). + */ override fun beta(): BetaServiceAsync = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun coupons(): CouponServiceAsync = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ override fun creditNotes(): CreditNoteServiceAsync = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun customers(): CustomerServiceAsync = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun events(): EventServiceAsync = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemServiceAsync = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoices(): InvoiceServiceAsync = invoices + /** + * 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. + */ override fun items(): ItemServiceAsync = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricServiceAsync = metrics + /** + * The [Plan](/core-concepts#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). + */ override fun plans(): PlanServiceAsync = plans + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceServiceAsync = prices override fun subscriptions(): SubscriptionServiceAsync = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertServiceAsync = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync = @@ -170,8 +255,16 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockServiceAsync = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ override fun licenseTypes(): LicenseTypeServiceAsync = licenseTypes override fun licenses(): LicenseServiceAsync = licenses @@ -267,31 +360,116 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel + /** + * The [Plan](/core-concepts#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). + */ override fun beta(): BetaServiceAsync.WithRawResponse = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun coupons(): CouponServiceAsync.WithRawResponse = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ override fun creditNotes(): CreditNoteServiceAsync.WithRawResponse = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun customers(): CustomerServiceAsync.WithRawResponse = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun events(): EventServiceAsync.WithRawResponse = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoices(): InvoiceServiceAsync.WithRawResponse = invoices + /** + * 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. + */ override fun items(): ItemServiceAsync.WithRawResponse = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricServiceAsync.WithRawResponse = metrics + /** + * The [Plan](/core-concepts#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). + */ override fun plans(): PlanServiceAsync.WithRawResponse = plans + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceServiceAsync.WithRawResponse = prices override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertServiceAsync.WithRawResponse = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse = @@ -300,8 +478,16 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ override fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse = licenseTypes override fun licenses(): LicenseServiceAsync.WithRawResponse = licenses diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index 14eaba40a..77f21264d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -129,30 +129,115 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun topLevel(): TopLevelService = topLevel + /** + * The [Plan](/core-concepts#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). + */ override fun beta(): BetaService = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun coupons(): CouponService = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ override fun creditNotes(): CreditNoteService = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun customers(): CustomerService = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun events(): EventService = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemService = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoices(): InvoiceService = invoices + /** + * 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. + */ override fun items(): ItemService = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricService = metrics + /** + * The [Plan](/core-concepts#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). + */ override fun plans(): PlanService = plans + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceService = prices override fun subscriptions(): SubscriptionService = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertService = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupService = dimensionalPriceGroups @@ -161,8 +246,16 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun subscriptionChanges(): SubscriptionChangeService = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockService = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ override fun licenseTypes(): LicenseTypeService = licenseTypes override fun licenses(): LicenseService = licenses @@ -255,30 +348,115 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun topLevel(): TopLevelService.WithRawResponse = topLevel + /** + * The [Plan](/core-concepts#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). + */ override fun beta(): BetaService.WithRawResponse = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun coupons(): CouponService.WithRawResponse = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ override fun creditNotes(): CreditNoteService.WithRawResponse = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun customers(): CustomerService.WithRawResponse = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun events(): EventService.WithRawResponse = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoices(): InvoiceService.WithRawResponse = invoices + /** + * 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. + */ override fun items(): ItemService.WithRawResponse = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricService.WithRawResponse = metrics + /** + * The [Plan](/core-concepts#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). + */ override fun plans(): PlanService.WithRawResponse = plans + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceService.WithRawResponse = prices override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertService.WithRawResponse = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse = @@ -287,8 +465,16 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockService.WithRawResponse = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ override fun licenseTypes(): LicenseTypeService.WithRawResponse = licenseTypes override fun licenses(): LicenseService.WithRawResponse = licenses diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt index aa938149e..d2cfaf90f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt @@ -17,6 +17,12 @@ import com.withorb.api.models.AlertListParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ interface AlertServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt index f1001fcc4..25c94b62a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt @@ -28,6 +28,12 @@ import com.withorb.api.models.AlertListParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ class AlertServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AlertServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt index e7bbc4072..6403539dd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion import com.withorb.api.services.async.beta.ExternalPlanIdServiceAsync +/** + * The [Plan](/core-concepts#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). + */ interface BetaServiceAsync { /** @@ -27,6 +32,11 @@ interface BetaServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): BetaServiceAsync + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdServiceAsync /** This endpoint allows the creation of a new plan version for an existing plan. */ @@ -81,6 +91,11 @@ interface BetaServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): BetaServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt index 11c505cb3..47a505dd0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt @@ -24,6 +24,11 @@ import com.withorb.api.models.PlanVersion import com.withorb.api.services.async.beta.ExternalPlanIdServiceAsync import com.withorb.api.services.async.beta.ExternalPlanIdServiceAsyncImpl +/** + * The [Plan](/core-concepts#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). + */ class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BetaServiceAsync { @@ -40,6 +45,11 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): BetaServiceAsync = BetaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId override suspend fun createPlanVersion( @@ -80,6 +90,11 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier).build() ) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId private val createPlanVersionHandler: Handler = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt index 133b9cfbb..c1d0d2a04 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt @@ -14,6 +14,12 @@ import com.withorb.api.models.CouponListPageAsync import com.withorb.api.models.CouponListParams import com.withorb.api.services.async.coupons.SubscriptionServiceAsync +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface CouponServiceAsync { /** @@ -28,6 +34,12 @@ interface CouponServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CouponServiceAsync + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionServiceAsync /** @@ -111,6 +123,12 @@ interface CouponServiceAsync { modifier: (ClientOptions.Builder) -> Unit ): CouponServiceAsync.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt index 2030a0419..59adbeaaa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt @@ -26,6 +26,12 @@ import com.withorb.api.models.CouponListParams import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import com.withorb.api.services.async.coupons.SubscriptionServiceAsyncImpl +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class CouponServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CouponServiceAsync { @@ -42,6 +48,12 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CouponServiceAsync = CouponServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionServiceAsync = subscriptions override suspend fun create( @@ -86,6 +98,12 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier).build() ) + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt index 727b1bd04..c2171dba4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditBlockServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt index d6fdc1b93..f1a4a7e52 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt @@ -23,6 +23,10 @@ import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt index 8c59f637b..ae6165fe0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt @@ -12,6 +12,10 @@ import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPageAsync import com.withorb.api.models.CreditNoteListParams +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ interface CreditNoteServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt index 8682bd524..472f5135a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt @@ -23,6 +23,10 @@ import com.withorb.api.models.CreditNoteListPageAsync import com.withorb.api.models.CreditNoteListPageResponse import com.withorb.api.models.CreditNoteListParams +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt index fda804288..7cbad07db 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt @@ -22,6 +22,24 @@ import com.withorb.api.services.async.customers.BalanceTransactionServiceAsync import com.withorb.api.services.async.customers.CostServiceAsync import com.withorb.api.services.async.customers.CreditServiceAsync +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CustomerServiceAsync { /** @@ -36,10 +54,50 @@ interface CustomerServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CustomerServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun costs(): CostServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionServiceAsync /** @@ -287,10 +345,50 @@ interface CustomerServiceAsync { modifier: (ClientOptions.Builder) -> Unit ): CustomerServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun costs(): CostServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt index 5f7104953..513222c30 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt @@ -36,6 +36,24 @@ import com.withorb.api.services.async.customers.CostServiceAsyncImpl import com.withorb.api.services.async.customers.CreditServiceAsync import com.withorb.api.services.async.customers.CreditServiceAsyncImpl +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { @@ -56,10 +74,50 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CustomerServiceAsync = CustomerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun costs(): CostServiceAsync = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditServiceAsync = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionServiceAsync = balanceTransactions override suspend fun create( @@ -151,10 +209,50 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier).build() ) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun costs(): CostServiceAsync.WithRawResponse = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditServiceAsync.WithRawResponse = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse = balanceTransactions diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt index 997d016de..ce9a4b146 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt @@ -17,6 +17,11 @@ import com.withorb.api.models.EventUpdateResponse import com.withorb.api.services.async.events.BackfillServiceAsync import com.withorb.api.services.async.events.VolumeServiceAsync +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface EventServiceAsync { /** @@ -31,8 +36,18 @@ interface EventServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): EventServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun backfills(): BackfillServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun volume(): VolumeServiceAsync /** @@ -370,8 +385,18 @@ interface EventServiceAsync { modifier: (ClientOptions.Builder) -> Unit ): EventServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun backfills(): BackfillServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun volume(): VolumeServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt index fa2432d6b..0777c0f78 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt @@ -29,6 +29,11 @@ import com.withorb.api.services.async.events.BackfillServiceAsyncImpl import com.withorb.api.services.async.events.VolumeServiceAsync import com.withorb.api.services.async.events.VolumeServiceAsyncImpl +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class EventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EventServiceAsync { @@ -45,8 +50,18 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): EventServiceAsync = EventServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun backfills(): BackfillServiceAsync = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun volume(): VolumeServiceAsync = volume override suspend fun update( @@ -98,8 +113,18 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier).build() ) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun backfills(): BackfillServiceAsync.WithRawResponse = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun volume(): VolumeServiceAsync.WithRawResponse = volume private val updateHandler: Handler = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt index eb20e781c..adfae61f3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt @@ -9,6 +9,13 @@ import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceLineItemServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt index 3de64012a..d21b5a92f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt @@ -18,6 +18,13 @@ import com.withorb.api.core.prepareAsync import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceLineItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index 86bafe2f2..567898a92 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -25,6 +25,13 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidParams +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt index 242b0fbd2..e854a49b8 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt @@ -37,6 +37,13 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidParams +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt index ce119d0f1..f4de178d7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.ItemListPageAsync import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams +/** + * 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. + */ interface ItemServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt index 0213d01a1..b58f307a9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt @@ -25,6 +25,11 @@ import com.withorb.api.models.ItemListPageResponse import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams +/** + * 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. + */ class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ItemServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt index e982d9523..52348f968 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.LicenseTypeListParams import com.withorb.api.models.LicenseTypeRetrieveParams import com.withorb.api.models.LicenseTypeRetrieveResponse +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ interface LicenseTypeServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt index d51f6d9c5..325ae1fed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt @@ -24,6 +24,10 @@ import com.withorb.api.models.LicenseTypeListParams import com.withorb.api.models.LicenseTypeRetrieveParams import com.withorb.api.models.LicenseTypeRetrieveResponse +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ class LicenseTypeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LicenseTypeServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt index ca300f0e7..55314ae2b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.MetricListPageAsync import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ interface MetricServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt index cd46a71a6..e67e43e29 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt @@ -24,6 +24,10 @@ import com.withorb.api.models.MetricListPageResponse import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ class MetricServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MetricServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt index f4fe6a1aa..8b21e1369 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt @@ -15,6 +15,11 @@ import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsync import com.withorb.api.services.async.plans.MigrationServiceAsync +/** + * The [Plan](/core-concepts#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). + */ interface PlanServiceAsync { /** @@ -29,8 +34,18 @@ interface PlanServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PlanServiceAsync + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdServiceAsync + /** + * The [Plan](/core-concepts#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). + */ fun migrations(): MigrationServiceAsync /** This endpoint allows creation of plans including their prices. */ @@ -118,8 +133,18 @@ interface PlanServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PlanServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun migrations(): MigrationServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt index 087f7dfa1..5711ae457 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt @@ -28,6 +28,11 @@ import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsyncImpl import com.withorb.api.services.async.plans.MigrationServiceAsync import com.withorb.api.services.async.plans.MigrationServiceAsyncImpl +/** + * The [Plan](/core-concepts#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). + */ class PlanServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PlanServiceAsync { @@ -48,8 +53,18 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PlanServiceAsync = PlanServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId + /** + * The [Plan](/core-concepts#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). + */ override fun migrations(): MigrationServiceAsync = migrations override suspend fun create(params: PlanCreateParams, requestOptions: RequestOptions): Plan = @@ -92,8 +107,18 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier).build() ) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId + /** + * The [Plan](/core-concepts#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). + */ override fun migrations(): MigrationServiceAsync.WithRawResponse = migrations private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt index ffca06049..8cc29ef12 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt @@ -46,6 +46,18 @@ import com.withorb.api.models.PriceListParams import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface PriceServiceAsync { /** @@ -60,6 +72,18 @@ interface PriceServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PriceServiceAsync + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdServiceAsync /** @@ -470,6 +494,18 @@ interface PriceServiceAsync { modifier: (ClientOptions.Builder) -> Unit ): PriceServiceAsync.WithRawResponse + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt index 65e8fcea4..4226dde19 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt @@ -32,6 +32,18 @@ import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsyncImpl +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class PriceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PriceServiceAsync { @@ -48,6 +60,18 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PriceServiceAsync = PriceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdServiceAsync = externalPriceId override suspend fun create(params: PriceCreateParams, requestOptions: RequestOptions): Price = @@ -107,6 +131,18 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier).build() ) + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse = externalPriceId diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt index c8a502ad8..bb45be258 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt @@ -12,6 +12,11 @@ import com.withorb.api.models.BetaExternalPlanIdSetDefaultPlanVersionParams import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion +/** + * The [Plan](/core-concepts#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). + */ interface ExternalPlanIdServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt index d938ea775..573f7fdde 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt @@ -22,6 +22,11 @@ import com.withorb.api.models.BetaExternalPlanIdSetDefaultPlanVersionParams import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion +/** + * The [Plan](/core-concepts#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). + */ class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt index db3b905a5..d820f0153 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt @@ -9,6 +9,12 @@ import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CouponSubscriptionListPageAsync import com.withorb.api.models.CouponSubscriptionListParams +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface SubscriptionServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt index f37d0b5d4..f2e11080c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt @@ -19,6 +19,12 @@ import com.withorb.api.models.CouponSubscriptionListPageAsync import com.withorb.api.models.CouponSubscriptionListParams import com.withorb.api.models.Subscriptions +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt index 8d2e1a554..fef07bb15 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt @@ -11,6 +11,24 @@ import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPageAsync import com.withorb.api.models.CustomerBalanceTransactionListParams +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface BalanceTransactionServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt index 4ee59d975..f1b961aed 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt @@ -22,6 +22,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListPageAsync import com.withorb.api.models.CustomerBalanceTransactionListPageResponse import com.withorb.api.models.CustomerBalanceTransactionListParams +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class BalanceTransactionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt index 330f3190f..852b1b831 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt @@ -11,6 +11,24 @@ import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CostServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt index 7e83a3a72..873322be0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt @@ -20,6 +20,24 @@ import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CostServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CostServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt index 27f96b76a..a7f5654e5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.CustomerCreditListParams import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import com.withorb.api.services.async.customers.credits.TopUpServiceAsync +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditServiceAsync { /** @@ -27,8 +31,16 @@ interface CreditServiceAsync { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CreditServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpServiceAsync /** @@ -120,8 +132,16 @@ interface CreditServiceAsync { modifier: (ClientOptions.Builder) -> Unit ): CreditServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpServiceAsync.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt index e244dd923..1f213dda6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.async.customers.credits.LedgerServiceAsyncImpl import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import com.withorb.api.services.async.customers.credits.TopUpServiceAsyncImpl +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync { @@ -42,8 +46,16 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CreditServiceAsync = CreditServiceAsyncImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerServiceAsync = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpServiceAsync = topUps override suspend fun list( @@ -81,8 +93,16 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier).build() ) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerServiceAsync.WithRawResponse = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpServiceAsync.WithRawResponse = topUps private val listHandler: Handler = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index bfec736a0..20e1e7b77 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -15,6 +15,10 @@ import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPageAsync import com.withorb.api.models.CustomerCreditLedgerListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface LedgerServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt index a95878533..dab840e74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt @@ -27,6 +27,10 @@ import com.withorb.api.models.CustomerCreditLedgerListPageAsync import com.withorb.api.models.CustomerCreditLedgerListPageResponse import com.withorb.api.models.CustomerCreditLedgerListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LedgerServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt index 83696b0ac..f1ac5a36a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt @@ -18,6 +18,10 @@ import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPageAsync import com.withorb.api.models.CustomerCreditTopUpListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface TopUpServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt index ff0b5ead8..3e962bcfc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt @@ -30,6 +30,10 @@ import com.withorb.api.models.CustomerCreditTopUpListPageAsync import com.withorb.api.models.CustomerCreditTopUpListPageResponse import com.withorb.api.models.CustomerCreditTopUpListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopUpServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt index 23c302c3f..733124cb5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt @@ -17,6 +17,11 @@ import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface BackfillServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt index 353cb1bc5..a8ba86619 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt @@ -28,6 +28,11 @@ import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BackfillServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt index cf8d0f5ca..b0f781aff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt @@ -9,6 +9,11 @@ import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface VolumeServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt index e00b975b8..c54888074 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt @@ -17,6 +17,11 @@ import com.withorb.api.core.prepareAsync import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class VolumeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : VolumeServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt index 65eef1201..2be45273e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt @@ -10,6 +10,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +/** + * The [Plan](/core-concepts#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). + */ interface ExternalPlanIdServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt index 6e11c7e30..4c8548e86 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt @@ -20,6 +20,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +/** + * The [Plan](/core-concepts#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). + */ class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt index d802c34a4..cd1121d1a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.PlanMigrationListParams import com.withorb.api.models.PlanMigrationRetrieveParams import com.withorb.api.models.PlanMigrationRetrieveResponse +/** + * The [Plan](/core-concepts#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). + */ interface MigrationServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt index 2389d51ae..3c732ff8c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt @@ -24,6 +24,11 @@ import com.withorb.api.models.PlanMigrationListParams import com.withorb.api.models.PlanMigrationRetrieveParams import com.withorb.api.models.PlanMigrationRetrieveResponse +/** + * The [Plan](/core-concepts#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). + */ class MigrationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MigrationServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt index 8326ebb25..1863cfb62 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt @@ -10,6 +10,18 @@ import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface ExternalPriceIdServiceAsync { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt index ec03384bc..312ebddce 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt @@ -20,6 +20,18 @@ import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class ExternalPriceIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdServiceAsync { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt index 151142084..3b5c4c048 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt @@ -17,6 +17,12 @@ import com.withorb.api.models.AlertListParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ interface AlertService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt index c0fa4b7c2..029804490 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt @@ -28,6 +28,12 @@ import com.withorb.api.models.AlertListParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ class AlertServiceImpl internal constructor(private val clientOptions: ClientOptions) : AlertService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt index 81f7b22c4..34a0d65d3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion import com.withorb.api.services.blocking.beta.ExternalPlanIdService +/** + * The [Plan](/core-concepts#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). + */ interface BetaService { /** @@ -27,6 +32,11 @@ interface BetaService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): BetaService + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdService /** This endpoint allows the creation of a new plan version for an existing plan. */ @@ -81,6 +91,11 @@ interface BetaService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): BetaService.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt index 2a3480b69..1ebb5a799 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt @@ -24,6 +24,11 @@ import com.withorb.api.models.PlanVersion import com.withorb.api.services.blocking.beta.ExternalPlanIdService import com.withorb.api.services.blocking.beta.ExternalPlanIdServiceImpl +/** + * The [Plan](/core-concepts#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). + */ class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { private val withRawResponse: BetaService.WithRawResponse by lazy { @@ -39,6 +44,11 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): BetaService = BetaServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdService = externalPlanId override fun createPlanVersion( @@ -77,6 +87,11 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti ): BetaService.WithRawResponse = BetaServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId private val createPlanVersionHandler: Handler = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt index fa46c93a6..9fee04394 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt @@ -14,6 +14,12 @@ import com.withorb.api.models.CouponListPage import com.withorb.api.models.CouponListParams import com.withorb.api.services.blocking.coupons.SubscriptionService +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface CouponService { /** @@ -28,6 +34,12 @@ interface CouponService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CouponService + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionService /** @@ -107,6 +119,12 @@ interface CouponService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CouponService.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt index eb536a2e8..b0fd17c80 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt @@ -26,6 +26,12 @@ import com.withorb.api.models.CouponListParams import com.withorb.api.services.blocking.coupons.SubscriptionService import com.withorb.api.services.blocking.coupons.SubscriptionServiceImpl +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class CouponServiceImpl internal constructor(private val clientOptions: ClientOptions) : CouponService { @@ -42,6 +48,12 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CouponService = CouponServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionService = subscriptions override fun create(params: CouponCreateParams, requestOptions: RequestOptions): Coupon = @@ -75,6 +87,12 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp ): CouponService.WithRawResponse = CouponServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt index 440db6477..cce94c002 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditBlockService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt index f1d921d7f..cb116b6f7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt @@ -23,6 +23,10 @@ import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditBlockServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt index 8820b7a1d..260bbc979 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt @@ -12,6 +12,10 @@ import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListParams +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ interface CreditNoteService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt index 650d6c78a..59404ad8e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt @@ -23,6 +23,10 @@ import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListPageResponse import com.withorb.api.models.CreditNoteListParams +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ class CreditNoteServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt index bc4ade3dc..d4cc6f1b9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt @@ -22,6 +22,24 @@ import com.withorb.api.services.blocking.customers.BalanceTransactionService import com.withorb.api.services.blocking.customers.CostService import com.withorb.api.services.blocking.customers.CreditService +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CustomerService { /** @@ -36,10 +54,50 @@ interface CustomerService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CustomerService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun costs(): CostService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionService /** @@ -277,10 +335,50 @@ interface CustomerService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CustomerService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun costs(): CostService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt index 351525072..03e5d352b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt @@ -36,6 +36,24 @@ import com.withorb.api.services.blocking.customers.CostServiceImpl import com.withorb.api.services.blocking.customers.CreditService import com.withorb.api.services.blocking.customers.CreditServiceImpl +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { @@ -56,10 +74,50 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CustomerService = CustomerServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun costs(): CostService = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditService = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionService = balanceTransactions override fun create(params: CustomerCreateParams, requestOptions: RequestOptions): Customer = @@ -142,10 +200,50 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier).build() ) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun costs(): CostService.WithRawResponse = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditService.WithRawResponse = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionService.WithRawResponse = balanceTransactions diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt index 34966dccd..957cdf825 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt @@ -17,6 +17,11 @@ import com.withorb.api.models.EventUpdateResponse import com.withorb.api.services.blocking.events.BackfillService import com.withorb.api.services.blocking.events.VolumeService +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface EventService { /** @@ -31,8 +36,18 @@ interface EventService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): EventService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun backfills(): BackfillService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun volume(): VolumeService /** @@ -368,8 +383,18 @@ interface EventService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): EventService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun backfills(): BackfillService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun volume(): VolumeService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt index 306e62ba2..148e7f4dc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt @@ -29,6 +29,11 @@ import com.withorb.api.services.blocking.events.BackfillServiceImpl import com.withorb.api.services.blocking.events.VolumeService import com.withorb.api.services.blocking.events.VolumeServiceImpl +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class EventServiceImpl internal constructor(private val clientOptions: ClientOptions) : EventService { @@ -45,8 +50,18 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): EventService = EventServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun backfills(): BackfillService = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun volume(): VolumeService = volume override fun update( @@ -96,8 +111,18 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt ): EventService.WithRawResponse = EventServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun backfills(): BackfillService.WithRawResponse = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun volume(): VolumeService.WithRawResponse = volume private val updateHandler: Handler = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt index 2080f3901..ea232ba9c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt @@ -9,6 +9,13 @@ import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceLineItemService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt index 6808d58e9..b5df5d2a2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt @@ -18,6 +18,13 @@ import com.withorb.api.core.prepare import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceLineItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index c85bc39fb..84b914233 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -25,6 +25,13 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidParams +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt index 396800250..8622376bd 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt @@ -37,6 +37,13 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidParams +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt index 5a74cfee4..d6494d4fb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.ItemListPage import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams +/** + * 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. + */ interface ItemService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt index 4e7484e6b..40e24bc0e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt @@ -25,6 +25,11 @@ import com.withorb.api.models.ItemListPageResponse import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams +/** + * 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. + */ class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { private val withRawResponse: ItemService.WithRawResponse by lazy { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt index 82097a370..fba3ca5ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.LicenseTypeListParams import com.withorb.api.models.LicenseTypeRetrieveParams import com.withorb.api.models.LicenseTypeRetrieveResponse +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ interface LicenseTypeService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt index 6646170a6..6a1f24721 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt @@ -24,6 +24,10 @@ import com.withorb.api.models.LicenseTypeListParams import com.withorb.api.models.LicenseTypeRetrieveParams import com.withorb.api.models.LicenseTypeRetrieveResponse +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ class LicenseTypeServiceImpl internal constructor(private val clientOptions: ClientOptions) : LicenseTypeService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt index 0924e68e5..b1a5eceee 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.MetricListPage import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ interface MetricService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt index 7104e4398..120aa2001 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt @@ -24,6 +24,10 @@ import com.withorb.api.models.MetricListPageResponse import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ class MetricServiceImpl internal constructor(private val clientOptions: ClientOptions) : MetricService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt index c2abd30bf..7cd76f559 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt @@ -15,6 +15,11 @@ import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.blocking.plans.ExternalPlanIdService import com.withorb.api.services.blocking.plans.MigrationService +/** + * The [Plan](/core-concepts#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). + */ interface PlanService { /** @@ -29,8 +34,18 @@ interface PlanService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PlanService + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdService + /** + * The [Plan](/core-concepts#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). + */ fun migrations(): MigrationService /** This endpoint allows creation of plans including their prices. */ @@ -115,8 +130,18 @@ interface PlanService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PlanService.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun externalPlanId(): ExternalPlanIdService.WithRawResponse + /** + * The [Plan](/core-concepts#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). + */ fun migrations(): MigrationService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt index 21f7b8675..ddbe99dd1 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt @@ -28,6 +28,11 @@ import com.withorb.api.services.blocking.plans.ExternalPlanIdServiceImpl import com.withorb.api.services.blocking.plans.MigrationService import com.withorb.api.services.blocking.plans.MigrationServiceImpl +/** + * The [Plan](/core-concepts#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). + */ class PlanServiceImpl internal constructor(private val clientOptions: ClientOptions) : PlanService { private val withRawResponse: PlanService.WithRawResponse by lazy { @@ -45,8 +50,18 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PlanService = PlanServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdService = externalPlanId + /** + * The [Plan](/core-concepts#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). + */ override fun migrations(): MigrationService = migrations override fun create(params: PlanCreateParams, requestOptions: RequestOptions): Plan = @@ -84,8 +99,18 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti ): PlanService.WithRawResponse = PlanServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Plan](/core-concepts#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). + */ override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId + /** + * The [Plan](/core-concepts#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). + */ override fun migrations(): MigrationService.WithRawResponse = migrations private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt index 2a18a20e1..f6c2332ff 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt @@ -46,6 +46,18 @@ import com.withorb.api.models.PriceListParams import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface PriceService { /** @@ -60,6 +72,18 @@ interface PriceService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PriceService + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdService /** @@ -468,6 +492,18 @@ interface PriceService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PriceService.WithRawResponse + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt index 7e3cb9be7..2dc13be96 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt @@ -32,6 +32,18 @@ import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService import com.withorb.api.services.blocking.prices.ExternalPriceIdServiceImpl +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class PriceServiceImpl internal constructor(private val clientOptions: ClientOptions) : PriceService { @@ -48,6 +60,18 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): PriceService = PriceServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdService = externalPriceId override fun create(params: PriceCreateParams, requestOptions: RequestOptions): Price = @@ -102,6 +126,18 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt ): PriceService.WithRawResponse = PriceServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdService.WithRawResponse = externalPriceId private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt index 85ce049dc..3deed2ed5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt @@ -12,6 +12,11 @@ import com.withorb.api.models.BetaExternalPlanIdSetDefaultPlanVersionParams import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion +/** + * The [Plan](/core-concepts#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). + */ interface ExternalPlanIdService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt index 23d063e0a..5cec1a2fc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt @@ -22,6 +22,11 @@ import com.withorb.api.models.BetaExternalPlanIdSetDefaultPlanVersionParams import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion +/** + * The [Plan](/core-concepts#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). + */ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt index 0cfc586f5..a4c9f53aa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt @@ -9,6 +9,12 @@ import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CouponSubscriptionListPage import com.withorb.api.models.CouponSubscriptionListParams +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface SubscriptionService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt index 22aa4e1fe..4fb9f8448 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt @@ -19,6 +19,12 @@ import com.withorb.api.models.CouponSubscriptionListPage import com.withorb.api.models.CouponSubscriptionListParams import com.withorb.api.models.Subscriptions +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt index 94c403abf..8dd3b29bb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt @@ -11,6 +11,24 @@ import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListParams +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface BalanceTransactionService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt index c383bacd9..37a2f1c4e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt @@ -22,6 +22,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListPageResponse import com.withorb.api.models.CustomerBalanceTransactionListParams +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class BalanceTransactionServiceImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt index 55da94ad8..edce00b07 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt @@ -11,6 +11,24 @@ import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CostService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt index 2e7b1ba0f..18ea21722 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt @@ -20,6 +20,24 @@ import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CostServiceImpl internal constructor(private val clientOptions: ClientOptions) : CostService { private val withRawResponse: CostService.WithRawResponse by lazy { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt index 98d912884..cec4583b3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.CustomerCreditListParams import com.withorb.api.services.blocking.customers.credits.LedgerService import com.withorb.api.services.blocking.customers.credits.TopUpService +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditService { /** @@ -27,8 +31,16 @@ interface CreditService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CreditService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpService /** @@ -113,8 +125,16 @@ interface CreditService { */ fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CreditService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpService.WithRawResponse /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt index 6b8715ac8..5177273fa 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.blocking.customers.credits.LedgerServiceImpl import com.withorb.api.services.blocking.customers.credits.TopUpService import com.withorb.api.services.blocking.customers.credits.TopUpServiceImpl +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditService { @@ -42,8 +46,16 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): CreditService = CreditServiceImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerService = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpService = topUps override fun list( @@ -79,8 +91,16 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp ): CreditService.WithRawResponse = CreditServiceImpl.WithRawResponseImpl(clientOptions.toBuilder().apply(modifier).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerService.WithRawResponse = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpService.WithRawResponse = topUps private val listHandler: Handler = diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index 10ba63968..74bfa5c1f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -15,6 +15,10 @@ import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPage import com.withorb.api.models.CustomerCreditLedgerListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface LedgerService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt index 86b471616..40a79d722 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt @@ -27,6 +27,10 @@ import com.withorb.api.models.CustomerCreditLedgerListPage import com.withorb.api.models.CustomerCreditLedgerListPageResponse import com.withorb.api.models.CustomerCreditLedgerListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOptions) : LedgerService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt index e32bb9d23..dbf16c59a 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt @@ -18,6 +18,10 @@ import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface TopUpService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt index b5b3479f3..297ff1771 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt @@ -30,6 +30,10 @@ import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListPageResponse import com.withorb.api.models.CustomerCreditTopUpListParams +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopUpService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt index 20e067321..5a4e55cf0 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt @@ -17,6 +17,11 @@ import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface BackfillService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt index f6a5e0982..8c4dde0ba 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt @@ -28,6 +28,11 @@ import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class BackfillServiceImpl internal constructor(private val clientOptions: ClientOptions) : BackfillService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt index dceade3d7..1ed61f999 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt @@ -9,6 +9,11 @@ import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface VolumeService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt index ae6a8061a..d0000476c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt @@ -17,6 +17,11 @@ import com.withorb.api.core.prepare import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class VolumeServiceImpl internal constructor(private val clientOptions: ClientOptions) : VolumeService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt index 1c1f345d6..8da809cb6 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt @@ -10,6 +10,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +/** + * The [Plan](/core-concepts#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). + */ interface ExternalPlanIdService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt index f7b9e40d8..da7a1e37e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt @@ -20,6 +20,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +/** + * The [Plan](/core-concepts#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). + */ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt index e043c4b32..18950da91 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.PlanMigrationListParams import com.withorb.api.models.PlanMigrationRetrieveParams import com.withorb.api.models.PlanMigrationRetrieveResponse +/** + * The [Plan](/core-concepts#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). + */ interface MigrationService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt index dcdddf81e..9dc4ce740 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt @@ -24,6 +24,11 @@ import com.withorb.api.models.PlanMigrationListParams import com.withorb.api.models.PlanMigrationRetrieveParams import com.withorb.api.models.PlanMigrationRetrieveResponse +/** + * The [Plan](/core-concepts#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). + */ class MigrationServiceImpl internal constructor(private val clientOptions: ClientOptions) : MigrationService { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt index 2d0b05e3f..6044906b3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt @@ -10,6 +10,18 @@ import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface ExternalPriceIdService { /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt index d2e2d5acb..8fc215310 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt @@ -20,6 +20,18 @@ import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +/** + * 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. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdService { From fe15a1ef1f9ecba723e359bcba1f36a629d3d960 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:23:40 +0000 Subject: [PATCH 21/52] feat(api): api update --- .stats.yml | 4 +- .../withorb/api/models/InvoiceCreateParams.kt | 103 ++++++++++++- .../withorb/api/models/InvoiceUpdateParams.kt | 135 ++++++++++++++++-- .../api/services/async/InvoiceServiceAsync.kt | 12 +- .../api/services/blocking/InvoiceService.kt | 12 +- .../api/models/InvoiceCreateParamsTest.kt | 3 + .../api/models/InvoiceUpdateParamsTest.kt | 3 + .../services/async/InvoiceServiceAsyncTest.kt | 2 + .../services/blocking/InvoiceServiceTest.kt | 2 + 9 files changed, 249 insertions(+), 27 deletions(-) diff --git a/.stats.yml b/.stats.yml index add28a88b..2be12a8b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0186c0310e2a9f40302cc35f4248fca335b7ec8069502f684ba6f2fa37793033.yml -openapi_spec_hash: 4fb1d2837ad3794864a7d59d393d6ff6 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5bb582f84f0b4cf7bef84833fefd48a5f2734dc25805da2028fd8a6f1198da07.yml +openapi_spec_hash: ced0e30dc67faa2414df511819408f12 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 5a718173f..b2bca296c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -65,6 +65,15 @@ private constructor( */ fun lineItems(): List = body.lineItems() + /** + * Determines whether this invoice will automatically attempt to charge a saved payment method, + * if any. If not specified, the invoice inherits the customer's auto_collection setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoCollection(): Boolean? = body.autoCollection() + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -161,6 +170,13 @@ private constructor( */ fun _lineItems(): JsonField> = body._lineItems() + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoCollection(): JsonField = body._autoCollection() + /** * Returns the raw JSON value of [customerId]. * @@ -264,8 +280,8 @@ private constructor( * - [currency] * - [invoiceDate] * - [lineItems] + * - [autoCollection] * - [customerId] - * - [discount] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -318,6 +334,31 @@ private constructor( */ fun addLineItem(lineItem: LineItem) = apply { body.addLineItem(lineItem) } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + */ + fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -653,6 +694,7 @@ private constructor( private val currency: JsonField, private val invoiceDate: JsonField, private val lineItems: JsonField>, + private val autoCollection: JsonField, private val customerId: JsonField, private val discount: JsonField, private val dueDate: JsonField, @@ -675,6 +717,9 @@ private constructor( @JsonProperty("line_items") @ExcludeMissing lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), @JsonProperty("customer_id") @ExcludeMissing customerId: JsonField = JsonMissing.of(), @@ -699,6 +744,7 @@ private constructor( currency, invoiceDate, lineItems, + autoCollection, customerId, discount, dueDate, @@ -733,6 +779,16 @@ private constructor( */ fun lineItems(): List = lineItems.getRequired("line_items") + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Boolean? = autoCollection.getNullable("auto_collection") + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -833,6 +889,16 @@ private constructor( @ExcludeMissing fun _lineItems(): JsonField> = lineItems + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + /** * Returns the raw JSON value of [customerId]. * @@ -930,6 +996,7 @@ private constructor( private var currency: JsonField? = null private var invoiceDate: JsonField? = null private var lineItems: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() private var discount: JsonField = JsonMissing.of() private var dueDate: JsonField = JsonMissing.of() @@ -944,6 +1011,7 @@ private constructor( currency = body.currency invoiceDate = body.invoiceDate lineItems = body.lineItems.map { it.toMutableList() } + autoCollection = body.autoCollection customerId = body.customerId discount = body.discount dueDate = body.dueDate @@ -1012,6 +1080,32 @@ private constructor( } } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -1253,6 +1347,7 @@ private constructor( checkRequired("currency", currency), checkRequired("invoiceDate", invoiceDate), checkRequired("lineItems", lineItems).map { it.toImmutable() }, + autoCollection, customerId, discount, dueDate, @@ -1275,6 +1370,7 @@ private constructor( currency() invoiceDate() lineItems().forEach { it.validate() } + autoCollection() customerId() discount()?.validate() dueDate()?.validate() @@ -1304,6 +1400,7 @@ private constructor( (if (currency.asKnown() == null) 0 else 1) + (if (invoiceDate.asKnown() == null) 0 else 1) + (lineItems.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown() == null) 0 else 1) + (if (customerId.asKnown() == null) 0 else 1) + (discount.asKnown()?.validity() ?: 0) + (dueDate.asKnown()?.validity() ?: 0) + @@ -1322,6 +1419,7 @@ private constructor( currency == other.currency && invoiceDate == other.invoiceDate && lineItems == other.lineItems && + autoCollection == other.autoCollection && customerId == other.customerId && discount == other.discount && dueDate == other.dueDate && @@ -1338,6 +1436,7 @@ private constructor( currency, invoiceDate, lineItems, + autoCollection, customerId, discount, dueDate, @@ -1353,7 +1452,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" + "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, autoCollection=$autoCollection, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" } class LineItem diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index 803e18d89..87ce4e73c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -32,13 +32,13 @@ import java.util.Collections import java.util.Objects /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and `invoice_date` - * properties on an invoice. If you pass null for the metadata value, it will clear any existing - * metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, and + * `auto_collection` properties 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. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can only - * be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` can only be modified if the invoice is in a `draft` state. `invoice_date` + * can only be modified for non-subscription invoices. */ class InvoiceUpdateParams private constructor( @@ -50,6 +50,16 @@ private constructor( fun invoiceId(): String? = invoiceId + /** + * Determines whether this invoice will automatically attempt to charge a saved payment method, + * if any. Can only be modified on draft invoices. If not specified, the invoice's existing + * setting is unchanged. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoCollection(): Boolean? = body.autoCollection() + /** * An optional custom due date for the invoice. If not set, the due date will be calculated * based on the `net_terms` value. @@ -89,6 +99,13 @@ private constructor( */ fun netTerms(): Long? = body.netTerms() + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoCollection(): JsonField = body._autoCollection() + /** * Returns the raw JSON value of [dueDate]. * @@ -157,13 +174,40 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [autoCollection] * - [dueDate] * - [invoiceDate] * - [metadata] * - [netTerms] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the invoice's + * existing setting is unchanged. + */ + fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * An optional custom due date for the invoice. If not set, the due date will be calculated * based on the `net_terms` value. @@ -390,6 +434,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val autoCollection: JsonField, private val dueDate: JsonField, private val invoiceDate: JsonField, private val metadata: JsonField, @@ -399,6 +444,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), @JsonProperty("due_date") @ExcludeMissing dueDate: JsonField = JsonMissing.of(), @@ -409,7 +457,17 @@ private constructor( @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), - ) : this(dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) + ) : this(autoCollection, dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) + + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the invoice's + * existing setting is unchanged. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Boolean? = autoCollection.getNullable("auto_collection") /** * An optional custom due date for the invoice. If not set, the due date will be calculated @@ -450,6 +508,16 @@ private constructor( */ fun netTerms(): Long? = netTerms.getNullable("net_terms") + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + /** * Returns the raw JSON value of [dueDate]. * @@ -501,6 +569,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var autoCollection: JsonField = JsonMissing.of() private var dueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() @@ -508,6 +577,7 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { + autoCollection = body.autoCollection dueDate = body.dueDate invoiceDate = body.invoiceDate metadata = body.metadata @@ -515,6 +585,32 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the + * invoice's existing setting is unchanged. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -624,7 +720,14 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(dueDate, invoiceDate, metadata, netTerms, additionalProperties.toMutableMap()) + Body( + autoCollection, + dueDate, + invoiceDate, + metadata, + netTerms, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -634,6 +737,7 @@ private constructor( return@apply } + autoCollection() dueDate()?.validate() invoiceDate()?.validate() metadata()?.validate() @@ -656,7 +760,8 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (dueDate.asKnown()?.validity() ?: 0) + + (if (autoCollection.asKnown() == null) 0 else 1) + + (dueDate.asKnown()?.validity() ?: 0) + (invoiceDate.asKnown()?.validity() ?: 0) + (metadata.asKnown()?.validity() ?: 0) + (if (netTerms.asKnown() == null) 0 else 1) @@ -667,6 +772,7 @@ private constructor( } return other is Body && + autoCollection == other.autoCollection && dueDate == other.dueDate && invoiceDate == other.invoiceDate && metadata == other.metadata && @@ -675,13 +781,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(dueDate, invoiceDate, metadata, netTerms, additionalProperties) + Objects.hash( + autoCollection, + dueDate, + invoiceDate, + metadata, + netTerms, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" + "Body{autoCollection=$autoCollection, dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" } /** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index 567898a92..c667be2ab 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -53,13 +53,13 @@ interface InvoiceServiceAsync { ): Invoice /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and - * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will - * clear any existing metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` properties 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. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can - * only be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, + * `invoice_date`, and `auto_collection` can only be modified if the invoice is in a `draft` + * state. `invoice_date` can only be modified for non-subscription invoices. */ suspend fun update( invoiceId: String, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index 84b914233..9f657098e 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -53,13 +53,13 @@ interface InvoiceService { ): Invoice /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and - * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will - * clear any existing metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` properties 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. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can - * only be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, + * `invoice_date`, and `auto_collection` can only be modified if the invoice is in a `draft` + * state. `invoice_date` can only be modified for non-subscription invoices. */ fun update( invoiceId: String, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 94c7f4107..9771e33e5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -28,6 +28,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -77,6 +78,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -124,6 +126,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + assertThat(body.autoCollection()).isEqualTo(true) assertThat(body.customerId()).isEqualTo("4khy3nwzktxv7") assertThat(body.discount()) .isEqualTo( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt index 4578f5f69..fc7d95012 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt @@ -13,6 +13,7 @@ internal class InvoiceUpdateParamsTest { fun create() { InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -38,6 +39,7 @@ internal class InvoiceUpdateParamsTest { val params = InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -50,6 +52,7 @@ internal class InvoiceUpdateParamsTest { val body = params._body() + assertThat(body.autoCollection()).isEqualTo(true) assertThat(body.dueDate()) .isEqualTo(InvoiceUpdateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.invoiceDate()) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 6888c68dd..419d1059e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -52,6 +52,7 @@ internal class InvoiceServiceAsyncTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -98,6 +99,7 @@ internal class InvoiceServiceAsyncTest { invoiceServiceAsync.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 1483cb75b..939d58e04 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -52,6 +52,7 @@ internal class InvoiceServiceTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -98,6 +99,7 @@ internal class InvoiceServiceTest { invoiceService.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( From 723f156299560f9a997cdb75603fc96dcbbe6906 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 04:23:13 +0000 Subject: [PATCH 22/52] feat(api): api update --- .stats.yml | 4 +- .../api/models/BetaCreatePlanVersionParams.kt | 141242 ++++++++++++++- ...taExternalPlanIdCreatePlanVersionParams.kt | 141242 ++++++++++++++- ...editLedgerCreateEntryByExternalIdParams.kt | 4 +- .../CustomerCreditLedgerCreateEntryParams.kt | 4 +- .../withorb/api/models/PlanCreateParams.kt | 67749 ++++++- .../customers/credits/LedgerServiceAsync.kt | 8 +- .../customers/credits/LedgerService.kt | 8 +- .../models/BetaCreatePlanVersionParamsTest.kt | 407 + ...ternalPlanIdCreatePlanVersionParamsTest.kt | 452 + .../api/models/PlanCreateParamsTest.kt | 190 + .../services/async/BetaServiceAsyncTest.kt | 155 + .../services/async/PlanServiceAsyncTest.kt | 70 + .../beta/ExternalPlanIdServiceAsyncTest.kt | 162 + .../api/services/blocking/BetaServiceTest.kt | 155 + .../api/services/blocking/PlanServiceTest.kt | 70 + .../beta/ExternalPlanIdServiceTest.kt | 162 + 17 files changed, 343379 insertions(+), 8705 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2be12a8b5..95afb0ace 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5bb582f84f0b4cf7bef84833fefd48a5f2734dc25805da2028fd8a6f1198da07.yml -openapi_spec_hash: ced0e30dc67faa2414df511819408f12 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-dafe9f726a47bdf7e506af8f10c6abcf4321dcc58106ce2b806a918778dfe2be.yml +openapi_spec_hash: 8e9827f2e8818d011e6afb203adb825f config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index 49d240389..af8a77e99 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1676,6 +1676,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1686,11 +1687,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1700,6 +1704,15 @@ private constructor( */ fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): LicenseAllocationPrice? = + licenseAllocationPrice.getNullable("license_allocation_price") + /** * The phase to add this price to. * @@ -1726,6 +1739,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1765,12 +1788,14 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(addPrice: AddPrice) = apply { allocationPrice = addPrice.allocationPrice + licenseAllocationPrice = addPrice.licenseAllocationPrice planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price additionalProperties = addPrice.additionalProperties.toMutableMap() @@ -1791,6 +1816,324 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -2011,6 +2354,7 @@ private constructor( fun build(): AddPrice = AddPrice( allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap(), @@ -2025,6 +2369,7 @@ private constructor( } allocationPrice()?.validate() + licenseAllocationPrice()?.validate() planPhaseOrder() price()?.validate() validated = true @@ -2046,115 +2391,111 @@ private constructor( */ internal fun validity(): Int = (allocationPrice.asKnown()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { - fun unit(): NewPlanUnitPrice? = unit + fun unit(): Unit? = unit - fun tiered(): NewPlanTieredPrice? = tiered + fun tiered(): Tiered? = tiered - fun bulk(): NewPlanBulkPrice? = bulk + fun bulk(): Bulk? = bulk fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters - fun package_(): NewPlanPackagePrice? = package_ + fun package_(): Package? = package_ - fun matrix(): NewPlanMatrixPrice? = matrix + fun matrix(): Matrix? = matrix - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun tieredPackage(): TieredPackage? = tieredPackage - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + fun tieredWithMinimum(): TieredWithMinimum? = tieredWithMinimum - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + fun groupedTiered(): GroupedTiered? = groupedTiered - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun tieredPackageWithMinimum(): TieredPackageWithMinimum? = tieredPackageWithMinimum - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + fun packageWithAllocation(): PackageWithAllocation? = packageWithAllocation - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun unitWithPercent(): UnitWithPercent? = unitWithPercent - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun matrixWithAllocation(): MatrixWithAllocation? = matrixWithAllocation fun tieredWithProration(): TieredWithProration? = tieredWithProration - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun unitWithProration(): UnitWithProration? = unitWithProration - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun groupedAllocation(): GroupedAllocation? = groupedAllocation - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun bulkWithProration(): BulkWithProration? = bulkWithProration - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + fun groupedWithProratedMinimum(): GroupedWithProratedMinimum? = groupedWithProratedMinimum - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + fun groupedWithMeteredMinimum(): GroupedWithMeteredMinimum? = groupedWithMeteredMinimum fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun groupedTieredPackage(): GroupedTieredPackage? = groupedTieredPackage - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun maxGroupTieredPackage(): MaxGroupTieredPackage? = maxGroupTieredPackage - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + fun scalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing? = scalableMatrixWithUnitPricing - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + fun scalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing? = scalableMatrixWithTieredPricing - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = cumulativeGroupedAllocation - fun minimumComposite(): NewPlanMinimumCompositePrice? = minimumComposite + fun minimumComposite(): MinimumComposite? = minimumComposite fun percent(): Percent? = percent @@ -2223,85 +2564,82 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun asMinimumComposite(): NewPlanMinimumCompositePrice = + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2365,22 +2703,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): LicenseAllocationPrice = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitTiered(tiered: NewPlanTieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -2388,54 +2726,50 @@ private constructor( bulkWithFilters.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { + override fun visitPackage(package_: Package) { package_.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) { matrixWithAllocation.validate() } @@ -2446,32 +2780,26 @@ private constructor( tieredWithProration.validate() } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } @@ -2483,38 +2811,37 @@ private constructor( } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -2525,9 +2852,7 @@ private constructor( cumulativeGroupedAllocation.validate() } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -2560,72 +2885,66 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = bulkWithFilters.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) = thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) = matrixWithAllocation.validity() override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitGroupedWithMinMaxThresholds( @@ -2633,37 +2952,35 @@ private constructor( ) = groupedWithMinMaxThresholds.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) = groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -2679,7 +2996,7 @@ private constructor( return true } - return other is Price && + return other is LicenseAllocationPrice && unit == other.unit && tiered == other.tiered && bulk == other.bulk && @@ -2750,496 +3067,493 @@ private constructor( override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } companion object { - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + LicenseAllocationPrice(tieredWithProration = tieredWithProration) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) - fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) } /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. */ interface Visitor { - fun visitUnit(unit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitTiered(tiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - fun visitPackage(package_: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T fun visitGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T fun visitEventOutput(eventOutput: EventOutput): T /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") } } - internal class Deserializer : BaseDeserializer(Price::class) { + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Price { + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { val json = JsonValue.fromJsonNode(node) val modelType = json.asObject()?.get("model_type")?.asString() when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_filters" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_allocation" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "percent" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } } - return Price(_json = json) + return LicenseAllocationPrice(_json = json) } } - internal class Serializer : BaseSerializer(Price::class) { + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { override fun serialize( - value: Price, + value: LicenseAllocationPrice, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -3298,19 +3612,20 @@ private constructor( value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } } } - class BulkWithFilters + class Unit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val unitConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3331,21 +3646,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3392,11 +3710,12 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3415,39 +3734,41 @@ private constructor( ) /** - * Configuration for bulk_with_filters pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3464,6 +3785,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3591,17 +3921,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -3620,6 +3939,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -3628,6 +3957,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3786,27 +4125,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") 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 = @@ -3829,45 +4171,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - licenseTypeId = bulkWithFilters.licenseTypeId - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3892,13 +4219,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3918,6 +4277,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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. @@ -4262,27 +4635,31 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("unitConfig", unitConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4303,20 +4680,21 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): Unit = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("unit")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + unitConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -4349,11 +4727,12 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (unitConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -4369,62 +4748,241 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Property filters to apply (all must match) + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun amount(): String = amount.getRequired("amount") /** - * Bulk tiers for rating based on total usage volume + * The currency of the license allocation. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun currency(): String = currency.getRequired("currency") /** - * Returns the raw JSON value of [filters]. + * When True, overage beyond the allocation is written off. * - * Unlike [filters], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - fun _filters(): JsonField> = filters + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [currency]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") + @JsonProperty("currency") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4442,84 +5000,81 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .filters() - * .tiers() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var filters: JsonField>? = null - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Adds a single [Filter] to [filters]. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -4545,35 +5100,37 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .filters() - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - filters().forEach { it.validate() } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -4592,749 +5149,153 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - */ - fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - propertyKey() - propertyValue() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (propertyKey.asKnown() == null) 0 else 1) + - (if (propertyValue.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } - - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): String? = - tierLowerBound.getNullable("tier_lower_bound") - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns an immutable instance of [Metadata]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - unitAmount() - tierLowerBound() - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + validated = true + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is Unit && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -5354,11 +5315,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5380,17 +5342,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class Tiered @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, + private val tieredConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5417,16 +5380,18 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), + tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5475,9 +5440,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5513,12 +5479,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5536,14 +5514,13 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Configuration for tiered_with_proration pricing + * Configuration for tiered pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") /** * The id of the billable metric for the price. Only needed if the price is @@ -5690,6 +5667,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -5699,15 +5686,14 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [tieredWithProrationConfig]. + * Returns the raw JSON value of [tieredConfig]. * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + fun _tieredConfig(): JsonField = tieredConfig /** * Returns the raw JSON value of [billableMetricId]. @@ -5867,29 +5853,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = + private var licenseAllocations: JsonField>? = null + private var modelType: JsonValue = JsonValue.from("tiered") + 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 = @@ -5912,30 +5899,28 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - licenseTypeId = tieredWithProration.licenseTypeId - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -5962,13 +5947,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -5988,21 +6005,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * Sets [Builder.tieredConfig] to an arbitrary JSON value. * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } /** * The id of the billable metric for the price. Only needed if the price is @@ -6348,7 +6364,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6356,19 +6372,23 @@ private constructor( * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + checkRequired("tieredConfig", tieredConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6389,20 +6409,21 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() + tieredConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -6437,11 +6458,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (tieredConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -6614,40 +6634,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("amount") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [tiers]. + * The currency of the license allocation. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6665,58 +6729,81 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .tiers() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun currency(currency: JsonField) = apply { + this.currency = currency } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + /** - * Adds a single [Tier] to [tiers]. + * Alias for [Builder.writeOffOverage]. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * This unboxed primitive overload exists for backwards compatibility. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -6742,32 +6829,37 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -6786,247 +6878,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -7143,12 +7018,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is Tiered && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && + tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7170,9 +7046,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7194,16 +7071,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Bulk @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkConfig: JsonField, private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7226,17 +7103,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7289,9 +7167,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -7312,25 +7191,22 @@ private constructor( ) /** - * The cadence to bill for this price on. + * Configuration for bulk pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -7341,12 +7217,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7491,25 +7379,24 @@ private constructor( fun referenceId(): String? = referenceId.getNullable("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkConfig(): JsonField = bulkConfig /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cadence") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -7519,6 +7406,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -7685,30 +7582,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```kotlin + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7732,34 +7628,43 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -7773,29 +7678,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -7808,13 +7690,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8178,28 +8092,29 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -8222,16 +8137,17 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } + bulkConfig().validate() cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8268,12 +8184,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (bulkConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -8447,108 +8362,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + @JsonProperty("amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * The maximum amount to charge each group + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun amount(): String = amount.getRequired("amount") /** - * The minimum amount to charge each group, regardless of usage + * The currency of the license allocation. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun currency(): String = currency.getRequired("currency") /** - * The base price charged per group + * When True, overage beyond the allocation is written off. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [amount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("amount") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [currency]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [currency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("currency") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [writeOffOverage]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("write_off_overage") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8566,99 +8457,81 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun amount(amount: JsonField) = apply { this.amount = amount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -8684,41 +8557,37 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + amount() + currency() + writeOffOverage() validated = true } @@ -8737,38 +8606,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -8885,11 +8746,11 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Bulk && + bulkConfig == other.bulkConfig && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -8911,9 +8772,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -8937,16 +8799,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -8969,17 +8831,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -9032,9 +8895,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, - cumulativeGroupedAllocationConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -9055,25 +8919,23 @@ private constructor( ) /** - * The cadence to bill for this price on. + * Configuration for bulk_with_filters pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") /** - * Configuration for cumulative_grouped_allocation pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -9084,12 +8946,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9234,25 +9108,25 @@ private constructor( fun referenceId(): String? = referenceId.getNullable("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkWithFiltersConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_with_filters_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("cadence") @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -9262,6 +9136,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -9428,30 +9312,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9475,34 +9358,46 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - licenseTypeId = cumulativeGroupedAllocation.licenseTypeId - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9516,29 +9411,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9551,13 +9423,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9921,28 +9825,29 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -9965,16 +9870,17 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -10011,12 +9917,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -10033,272 +9938,62 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, - private val groupingKey: JsonField, - private val unitAmount: JsonField, + private val filters: JsonField>, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) - - /** - * The overall allocation across all groups - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") - - /** - * The allocation per individual group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * The event property used to group usage before applying allocations + * Property filters to apply (all must match) * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun filters(): List = filters.getRequired("filters") /** - * The amount to charge for each unit outside of the allocation + * Bulk tiers for rating based on total usage volume * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [cumulativeAllocation]. - * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("cumulative_allocation") - @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation - - /** - * Returns the raw JSON value of [groupAllocation]. - * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("group_allocation") - @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [filters]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [filters], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _filters(): JsonField> = filters /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [tiers]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("unit_amount") + @JsonProperty("tiers") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10316,99 +10011,84 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```kotlin - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null - private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null + private var filters: JsonField>? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) - /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Adds a single [Filter] to [filters]. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.tiers] with a well-typed `List` * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.unitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -10434,41 +10114,35 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), - checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() - groupingKey() - unitAmount() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } validated = true } @@ -10487,217 +10161,132537 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (cumulativeAllocation.asKnown() == null) 0 else 1) + - (if (groupAllocation.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && - groupingKey == other.groupingKey && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { - Objects.hash( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - additionalProperties, - ) - } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** A builder for [Filter]. */ + class Builder internal constructor() { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun toBuilder() = Builder().from(this) + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } - companion object { + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode(): Int = hashCode - return other is Metadata && - additionalProperties == other.additionalProperties + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - return other is CumulativeGroupedAllocation && - cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - licenseTypeId == other.licenseTypeId && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - private val hashCode: Int by lazy { - Objects.hash( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - licenseTypeId, - metadata, - referenceId, - additionalProperties, - ) - } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Package]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (packageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Matrix]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (percent.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProration]. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum_composite") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [minimumCompositeConfig]. + * + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_composite_config") + @ExcludeMissing + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumComposite]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumComposite]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum_composite") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumComposite]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumComposite = + MinimumComposite( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumComposite = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum_composite")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (minimumCompositeConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumComposite && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimumComposite(): NewPlanMinimumCompositePrice? = minimumComposite + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + 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 && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): LicenseAllocationPrice? = + licenseAllocationPrice.getNullable("license_allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + licenseAllocationPrice = replacePrice.licenseAllocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewPlanMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + licenseAllocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice + private constructor( + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: MinimumComposite? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Unit? = unit + + fun tiered(): Tiered? = tiered + + fun bulk(): Bulk? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): Package? = package_ + + fun matrix(): Matrix? = matrix + + fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount + + fun tieredPackage(): TieredPackage? = tieredPackage + + fun tieredWithMinimum(): TieredWithMinimum? = tieredWithMinimum + + fun groupedTiered(): GroupedTiered? = groupedTiered + + fun tieredPackageWithMinimum(): TieredPackageWithMinimum? = tieredPackageWithMinimum + + fun packageWithAllocation(): PackageWithAllocation? = packageWithAllocation + + fun unitWithPercent(): UnitWithPercent? = unitWithPercent + + fun matrixWithAllocation(): MatrixWithAllocation? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): UnitWithProration? = unitWithProration + + fun groupedAllocation(): GroupedAllocation? = groupedAllocation + + fun bulkWithProration(): BulkWithProration? = bulkWithProration + + fun groupedWithProratedMinimum(): GroupedWithProratedMinimum? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): GroupedWithMeteredMinimum? = groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName + + fun groupedTieredPackage(): GroupedTieredPackage? = groupedTieredPackage + + fun maxGroupTieredPackage(): MaxGroupTieredPackage? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimumComposite(): MinimumComposite? = minimumComposite + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): Unit = unit.getOrThrow("unit") + + fun asTiered(): Tiered = tiered.getOrThrow("tiered") + + fun asBulk(): Bulk = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): Package = package_.getOrThrow("package_") + + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): MatrixWithAllocation = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): MinimumComposite = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() + } + + override fun visitTiered(tiered: Tiered) { + tiered.validate() + } + + override fun visitBulk(bulk: Bulk) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: Package) { + package_.validate() + } + + override fun visitMatrix(matrix: Matrix) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: Unit) = unit.validity() + + override fun visitTiered(tiered: Tiered) = tiered.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: Package) = package_.validity() + + override fun visitMatrix(matrix: Matrix) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocationPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + + companion object { + + fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) + + fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) + + fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) + + fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + LicenseAllocationPrice(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) + + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) + + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) + + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) + + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: Unit): T + + fun visitTiered(tiered: Tiered): T + + fun visitBulk(bulk: Bulk): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: Package): T + + fun visitMatrix(matrix: Matrix): T + + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T + + fun visitTieredPackage(tieredPackage: TieredPackage): T + + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T + + fun visitGroupedTiered(groupedTiered: GroupedTiered): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ): T + + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T + + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T + + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: UnitWithProration): T + + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T + + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T + + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T + + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ): T + + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: MinimumComposite): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. + * + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") + } + } + + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + } + + return LicenseAllocationPrice(_json = json) + } + } + + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { + + override fun serialize( + value: LicenseAllocationPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + } + } + + class Unit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Unit]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Unit]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Unit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Unit = + Unit( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tiered = + Tiered( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tiered && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Bulk]. + * + * The following fields are required: + * ```kotlin + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Bulk]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Bulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Bulk = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Bulk && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Package]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (packageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Matrix]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (percent.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProration]. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class MinimumComposite @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10724,15 +142718,18 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10781,9 +142778,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10819,12 +142817,34 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10841,15 +142861,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10996,22 +143007,33 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [licenseAllocations]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations /** - * Returns the raw JSON value of [percentConfig]. + * Returns the raw JSON value of [minimumCompositeConfig]. * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("percent_config") + @JsonProperty("minimum_composite_config") @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [billableMetricId]. @@ -11171,27 +143193,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of [MinimumComposite]. * * The following fields are required: * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [MinimumComposite]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11214,27 +143239,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - licenseTypeId = percent.licenseTypeId - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -11261,13 +143289,60 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11287,21 +143362,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11646,7 +143706,7 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [MinimumComposite]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -11654,19 +143714,23 @@ private constructor( * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): MinimumComposite = + MinimumComposite( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11687,20 +143751,21 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): MinimumComposite = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("minimum_composite")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -11735,9 +143800,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (minimumCompositeConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -11910,39 +143976,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * What percent of the component subtotals to charge + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [percent]. + * The currency of the license allocation. * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - fun _percent(): JsonField = percent + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11960,39 +144071,82 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .percent() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } fun additionalProperties(additionalProperties: Map) = apply { @@ -12017,32 +144171,37 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - percent() + amount() + currency() + writeOffOverage() validated = true } @@ -12060,26 +144219,253 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } /** @@ -12196,12 +144582,13 @@ private constructor( return true } - return other is Percent && + return other is MinimumComposite && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12223,9 +144610,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12247,17 +144635,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12281,18 +144670,21 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12340,10 +144732,11 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12371,30 +144764,32 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12411,6 +144806,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12548,16 +144952,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -12566,6 +144960,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -12574,6 +144978,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -12732,27 +145146,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -12775,27 +145192,28 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - licenseTypeId = eventOutput.licenseTypeId - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -12810,21 +145228,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -12837,13 +145240,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12863,6 +145298,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13207,27 +145657,31 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13248,20 +145702,21 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13295,10 +145750,11 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13471,87 +145927,309 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") + @JsonProperty("amount") @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun defaultUnitRate(): String? = - defaultUnitRate.getNullable("default_unit_rate") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey - - /** - * Returns the raw JSON value of [defaultUnitRate]. - * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_unit_rate") - @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13569,84 +146247,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } - - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -13671,36 +146304,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -13718,36 +146347,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (defaultUnitRate.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -13864,12 +146483,13 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -13890,10 +146510,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13915,1508 +146536,2019 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } - - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId - - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { - - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } - - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun hashCode(): Int = hashCode + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_id") - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - companion object { + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } - priceId() - planPhaseOrder() - validated = true - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - companion object { + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(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( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - private var validated: Boolean = 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 metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun minimum(): NewMinimum? = minimum + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun maximum(): NewMaximum? = maximum + private var validated: Boolean = false - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun isUsageDiscount(): Boolean = usageDiscount != null + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } - fun isAmountDiscount(): Boolean = amountDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isMinimum(): Boolean = minimum != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun isMaximum(): Boolean = maximum != null + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + companion object { - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + val ANNUAL = of("annual") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + val SEMI_ANNUAL = of("semi_annual") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + val MONTHLY = of("monthly") - fun _json(): JsonValue? = _json + val QUARTERLY = of("quarterly") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + val ONE_TIME = of("one_time") - private var validated: Boolean = false + val CUSTOM = of("custom") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + known() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is Cadence && value == other.value } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - companion object { + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + companion object { - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - fun visitMinimum(minimum: NewMinimum): T + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun visitMaximum(maximum: NewMaximum): T + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true } - } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = hashCode + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun hashCode(): Int = hashCode - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) - fun toBuilder() = Builder().from(this) + companion object { - companion object { + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + amount() + currency() + writeOffOverage() + validated = true + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + companion object { - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewPlanMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + validated = true + } - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - replacesPriceId() - allocationPrice()?.validate() - planPhaseOrder() - price()?.validate() - validated = true - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } /** New plan price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @@ -27296,6 +160428,7 @@ private constructor( return other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties @@ -27305,6 +160438,7 @@ private constructor( Objects.hash( replacesPriceId, allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties, @@ -27314,7 +160448,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index e6fcb3678..60760afea 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1681,6 +1681,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1691,11 +1692,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1705,6 +1709,15 @@ private constructor( */ fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): LicenseAllocationPrice? = + licenseAllocationPrice.getNullable("license_allocation_price") + /** * The phase to add this price to. * @@ -1731,6 +1744,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1770,12 +1793,14 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(addPrice: AddPrice) = apply { allocationPrice = addPrice.allocationPrice + licenseAllocationPrice = addPrice.licenseAllocationPrice planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price additionalProperties = addPrice.additionalProperties.toMutableMap() @@ -1796,6 +1821,324 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -2016,6 +2359,7 @@ private constructor( fun build(): AddPrice = AddPrice( allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap(), @@ -2030,6 +2374,7 @@ private constructor( } allocationPrice()?.validate() + licenseAllocationPrice()?.validate() planPhaseOrder() price()?.validate() validated = true @@ -2051,115 +2396,111 @@ private constructor( */ internal fun validity(): Int = (allocationPrice.asKnown()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { - fun unit(): NewPlanUnitPrice? = unit + fun unit(): Unit? = unit - fun tiered(): NewPlanTieredPrice? = tiered + fun tiered(): Tiered? = tiered - fun bulk(): NewPlanBulkPrice? = bulk + fun bulk(): Bulk? = bulk fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters - fun package_(): NewPlanPackagePrice? = package_ + fun package_(): Package? = package_ - fun matrix(): NewPlanMatrixPrice? = matrix + fun matrix(): Matrix? = matrix - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun tieredPackage(): TieredPackage? = tieredPackage - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + fun tieredWithMinimum(): TieredWithMinimum? = tieredWithMinimum - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + fun groupedTiered(): GroupedTiered? = groupedTiered - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun tieredPackageWithMinimum(): TieredPackageWithMinimum? = tieredPackageWithMinimum - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + fun packageWithAllocation(): PackageWithAllocation? = packageWithAllocation - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun unitWithPercent(): UnitWithPercent? = unitWithPercent - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun matrixWithAllocation(): MatrixWithAllocation? = matrixWithAllocation fun tieredWithProration(): TieredWithProration? = tieredWithProration - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun unitWithProration(): UnitWithProration? = unitWithProration - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun groupedAllocation(): GroupedAllocation? = groupedAllocation - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun bulkWithProration(): BulkWithProration? = bulkWithProration - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + fun groupedWithProratedMinimum(): GroupedWithProratedMinimum? = groupedWithProratedMinimum - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + fun groupedWithMeteredMinimum(): GroupedWithMeteredMinimum? = groupedWithMeteredMinimum fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun groupedTieredPackage(): GroupedTieredPackage? = groupedTieredPackage - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun maxGroupTieredPackage(): MaxGroupTieredPackage? = maxGroupTieredPackage - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + fun scalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing? = scalableMatrixWithUnitPricing - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + fun scalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing? = scalableMatrixWithTieredPricing - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = cumulativeGroupedAllocation - fun minimumComposite(): NewPlanMinimumCompositePrice? = minimumComposite + fun minimumComposite(): MinimumComposite? = minimumComposite fun percent(): Percent? = percent @@ -2228,85 +2569,82 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun asMinimumComposite(): NewPlanMinimumCompositePrice = + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2370,22 +2708,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): LicenseAllocationPrice = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitTiered(tiered: NewPlanTieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -2393,54 +2731,50 @@ private constructor( bulkWithFilters.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { + override fun visitPackage(package_: Package) { package_.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) { matrixWithAllocation.validate() } @@ -2451,32 +2785,26 @@ private constructor( tieredWithProration.validate() } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } @@ -2488,38 +2816,37 @@ private constructor( } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -2530,9 +2857,7 @@ private constructor( cumulativeGroupedAllocation.validate() } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -2565,72 +2890,66 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = bulkWithFilters.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) = thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) = matrixWithAllocation.validity() override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitGroupedWithMinMaxThresholds( @@ -2638,37 +2957,35 @@ private constructor( ) = groupedWithMinMaxThresholds.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) = groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -2684,7 +3001,7 @@ private constructor( return true } - return other is Price && + return other is LicenseAllocationPrice && unit == other.unit && tiered == other.tiered && bulk == other.bulk && @@ -2755,496 +3072,493 @@ private constructor( override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } companion object { - fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) - fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) - fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) - fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) - fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + LicenseAllocationPrice(tieredWithProration = tieredWithProration) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) - fun ofPercent(percent: Percent) = Price(percent = percent) + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) } /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. */ interface Visitor { - fun visitUnit(unit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitTiered(tiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - fun visitPackage(package_: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T fun visitGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T fun visitEventOutput(eventOutput: EventOutput): T /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") } } - internal class Deserializer : BaseDeserializer(Price::class) { + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Price { + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { val json = JsonValue.fromJsonNode(node) val modelType = json.asObject()?.get("model_type")?.asString() when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_filters" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_allocation" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "percent" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } } - return Price(_json = json) + return LicenseAllocationPrice(_json = json) } } - internal class Serializer : BaseSerializer(Price::class) { + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { override fun serialize( - value: Price, + value: LicenseAllocationPrice, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -3303,19 +3617,20 @@ private constructor( value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } } } - class BulkWithFilters + class Unit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val unitConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3336,21 +3651,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3397,11 +3715,12 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3420,39 +3739,41 @@ private constructor( ) /** - * Configuration for bulk_with_filters pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3469,6 +3790,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3596,17 +3926,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -3625,6 +3944,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -3633,6 +3962,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3791,27 +4130,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") 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 = @@ -3834,45 +4176,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - licenseTypeId = bulkWithFilters.licenseTypeId - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3897,13 +4224,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3923,6 +4282,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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. @@ -4267,27 +4640,31 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("unitConfig", unitConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4308,20 +4685,21 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): Unit = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("unit")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + unitConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -4354,11 +4732,12 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (unitConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -4374,62 +4753,241 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Property filters to apply (all must match) + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun amount(): String = amount.getRequired("amount") /** - * Bulk tiers for rating based on total usage volume + * The currency of the license allocation. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun currency(): String = currency.getRequired("currency") /** - * Returns the raw JSON value of [filters]. + * When True, overage beyond the allocation is written off. * - * Unlike [filters], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - fun _filters(): JsonField> = filters + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [currency]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") + @JsonProperty("currency") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4447,84 +5005,81 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .filters() - * .tiers() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var filters: JsonField>? = null - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Adds a single [Filter] to [filters]. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -4550,35 +5105,37 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .filters() - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - filters().forEach { it.validate() } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -4597,749 +5154,153 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - */ - fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - propertyKey() - propertyValue() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (propertyKey.asKnown() == null) 0 else 1) + - (if (propertyValue.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } - - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): String? = - tierLowerBound.getNullable("tier_lower_bound") - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns an immutable instance of [Metadata]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - unitAmount() - tierLowerBound() - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (unitAmount.asKnown() == null) 0 else 1) + - (if (tierLowerBound.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + validated = true + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is Unit && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -5359,11 +5320,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5385,17 +5347,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class Tiered @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, + private val tieredConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5422,16 +5385,18 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), + tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5480,9 +5445,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5518,12 +5484,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5541,14 +5519,13 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Configuration for tiered_with_proration pricing + * Configuration for tiered pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") /** * The id of the billable metric for the price. Only needed if the price is @@ -5695,6 +5672,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -5704,15 +5691,14 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [tieredWithProrationConfig]. + * Returns the raw JSON value of [tieredConfig]. * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + fun _tieredConfig(): JsonField = tieredConfig /** * Returns the raw JSON value of [billableMetricId]. @@ -5872,29 +5858,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = + private var licenseAllocations: JsonField>? = null + private var modelType: JsonValue = JsonValue.from("tiered") + 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 = @@ -5917,30 +5904,28 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - licenseTypeId = tieredWithProration.licenseTypeId - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -5967,13 +5952,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -5993,21 +6010,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * Sets [Builder.tieredConfig] to an arbitrary JSON value. * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } /** * The id of the billable metric for the price. Only needed if the price is @@ -6353,7 +6369,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6361,19 +6377,23 @@ private constructor( * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + checkRequired("tieredConfig", tieredConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6394,20 +6414,21 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() + tieredConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -6442,11 +6463,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (tieredConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -6619,40 +6639,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("amount") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [tiers]. + * The currency of the license allocation. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6670,58 +6734,81 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .tiers() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun currency(currency: JsonField) = apply { + this.currency = currency } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + /** - * Adds a single [Tier] to [tiers]. + * Alias for [Builder.writeOffOverage]. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * This unboxed primitive overload exists for backwards compatibility. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -6747,32 +6834,37 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -6791,247 +6883,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```kotlin - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (tierLowerBound.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -7148,12 +7023,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is Tiered && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && + tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7175,9 +7051,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7199,16 +7076,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Bulk @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkConfig: JsonField, private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7231,17 +7108,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7294,9 +7172,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -7317,25 +7196,22 @@ private constructor( ) /** - * The cadence to bill for this price on. + * Configuration for bulk pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -7346,12 +7222,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7496,25 +7384,24 @@ private constructor( fun referenceId(): String? = referenceId.getNullable("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkConfig(): JsonField = bulkConfig /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cadence") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -7524,6 +7411,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -7690,30 +7587,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```kotlin + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7737,34 +7633,43 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -7778,29 +7683,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -7813,13 +7695,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8183,28 +8097,29 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -8227,16 +8142,17 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } + bulkConfig().validate() cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8273,12 +8189,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (bulkConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -8452,108 +8367,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + @JsonProperty("amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * The maximum amount to charge each group + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun amount(): String = amount.getRequired("amount") /** - * The minimum amount to charge each group, regardless of usage + * The currency of the license allocation. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun currency(): String = currency.getRequired("currency") /** - * The base price charged per group + * When True, overage beyond the allocation is written off. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [amount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("amount") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [currency]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [currency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("currency") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [writeOffOverage]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("write_off_overage") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8571,99 +8462,81 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun amount(amount: JsonField) = apply { this.amount = amount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -8689,41 +8562,37 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + amount() + currency() + writeOffOverage() validated = true } @@ -8742,38 +8611,30 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (maximumCharge.asKnown() == null) 0 else 1) + - (if (minimumCharge.asKnown() == null) 0 else 1) + - (if (perUnitRate.asKnown() == null) 0 else 1) + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -8890,11 +8751,11 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Bulk && + bulkConfig == other.bulkConfig && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -8916,9 +8777,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -8942,16 +8804,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -8974,17 +8836,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -9037,9 +8900,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, - cumulativeGroupedAllocationConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -9060,25 +8924,23 @@ private constructor( ) /** - * The cadence to bill for this price on. + * Configuration for bulk_with_filters pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") /** - * Configuration for cumulative_grouped_allocation pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -9089,12 +8951,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9239,25 +9113,25 @@ private constructor( fun referenceId(): String? = referenceId.getNullable("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkWithFiltersConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_with_filters_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("cadence") @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -9267,6 +9141,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -9433,30 +9317,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9480,34 +9363,46 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - licenseTypeId = cumulativeGroupedAllocation.licenseTypeId - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9521,29 +9416,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9556,13 +9428,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9926,28 +9830,29 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -9970,16 +9875,17 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -10016,12 +9922,11 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (cadence.asKnown()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + @@ -10038,272 +9943,62 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - val ANNUAL = of("annual") - - val SEMI_ANNUAL = of("semi_annual") - - val MONTHLY = of("monthly") - - val QUARTERLY = of("quarterly") - - val ONE_TIME = of("one_time") - - val CUSTOM = of("custom") - - fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString() - ?: throw OrbInvalidDataException("Value is not a String") - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, - private val groupingKey: JsonField, - private val unitAmount: JsonField, + private val filters: JsonField>, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) - - /** - * The overall allocation across all groups - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") - - /** - * The allocation per individual group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * The event property used to group usage before applying allocations + * Property filters to apply (all must match) * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun filters(): List = filters.getRequired("filters") /** - * The amount to charge for each unit outside of the allocation + * Bulk tiers for rating based on total usage volume * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [cumulativeAllocation]. - * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("cumulative_allocation") - @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation - - /** - * Returns the raw JSON value of [groupAllocation]. - * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("group_allocation") - @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [filters]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [filters], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _filters(): JsonField> = filters /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [tiers]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("unit_amount") + @JsonProperty("tiers") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10321,99 +10016,84 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```kotlin - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` */ fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null - private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null + private var filters: JsonField>? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) - /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Adds a single [Filter] to [filters]. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.tiers] with a well-typed `List` * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.unitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -10439,41 +10119,35 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), - checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() - groupingKey() - unitAmount() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } validated = true } @@ -10492,217 +10166,132537 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (if (cumulativeAllocation.asKnown() == null) 0 else 1) + - (if (groupAllocation.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + - (if (unitAmount.asKnown() == null) 0 else 1) + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && - groupingKey == other.groupingKey && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private val hashCode: Int by lazy { - Objects.hash( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - additionalProperties, - ) - } + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** A builder for [Filter]. */ + class Builder internal constructor() { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun toBuilder() = Builder().from(this) + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } - companion object { + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - fun builder() = Builder() - } + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode(): Int = hashCode - return other is Metadata && - additionalProperties == other.additionalProperties + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = hashCode + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") - return other is CumulativeGroupedAllocation && - cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - licenseTypeId == other.licenseTypeId && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - private val hashCode: Int by lazy { - Objects.hash( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - licenseTypeId, - metadata, - referenceId, - additionalProperties, - ) - } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Package]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (packageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Matrix]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (percent.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProration]. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum_composite") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [minimumCompositeConfig]. + * + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_composite_config") + @ExcludeMissing + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumComposite]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumComposite]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum_composite") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumComposite]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumComposite = + MinimumComposite( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumComposite = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum_composite")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (minimumCompositeConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumComposite && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimumComposite(): NewPlanMinimumCompositePrice? = minimumComposite + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + fun ofPercent(percent: Percent) = Price(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + 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 && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (adjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (priceId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```kotlin + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (adjustment.asKnown()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + + fun usageDiscount(): NewUsageDiscount? = usageDiscount + + fun amountDiscount(): NewAmountDiscount? = amountDiscount + + fun minimum(): NewMinimum? = minimum + + fun maximum(): NewMaximum? = maximum + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): LicenseAllocationPrice? = + licenseAllocationPrice.getNullable("license_allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Price? = price.getNullable("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + licenseAllocationPrice = replacePrice.licenseAllocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewPlanMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice()?.validate() + licenseAllocationPrice()?.validate() + planPhaseOrder() + price()?.validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (replacesPriceId.asKnown() == null) 0 else 1) + + (allocationPrice.asKnown()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown() == null) 0 else 1) + + (price.asKnown()?.validity() ?: 0) + + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice + private constructor( + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: MinimumComposite? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Unit? = unit + + fun tiered(): Tiered? = tiered + + fun bulk(): Bulk? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): Package? = package_ + + fun matrix(): Matrix? = matrix + + fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount + + fun tieredPackage(): TieredPackage? = tieredPackage + + fun tieredWithMinimum(): TieredWithMinimum? = tieredWithMinimum + + fun groupedTiered(): GroupedTiered? = groupedTiered + + fun tieredPackageWithMinimum(): TieredPackageWithMinimum? = tieredPackageWithMinimum + + fun packageWithAllocation(): PackageWithAllocation? = packageWithAllocation + + fun unitWithPercent(): UnitWithPercent? = unitWithPercent + + fun matrixWithAllocation(): MatrixWithAllocation? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): UnitWithProration? = unitWithProration + + fun groupedAllocation(): GroupedAllocation? = groupedAllocation + + fun bulkWithProration(): BulkWithProration? = bulkWithProration + + fun groupedWithProratedMinimum(): GroupedWithProratedMinimum? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): GroupedWithMeteredMinimum? = groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName + + fun groupedTieredPackage(): GroupedTieredPackage? = groupedTieredPackage + + fun maxGroupTieredPackage(): MaxGroupTieredPackage? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimumComposite(): MinimumComposite? = minimumComposite + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): Unit = unit.getOrThrow("unit") + + fun asTiered(): Tiered = tiered.getOrThrow("tiered") + + fun asBulk(): Bulk = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): Package = package_.getOrThrow("package_") + + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): MatrixWithAllocation = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): MinimumComposite = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() + } + + override fun visitTiered(tiered: Tiered) { + tiered.validate() + } + + override fun visitBulk(bulk: Bulk) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: Package) { + package_.validate() + } + + override fun visitMatrix(matrix: Matrix) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: Unit) = unit.validity() + + override fun visitTiered(tiered: Tiered) = tiered.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: Package) = package_.validity() + + override fun visitMatrix(matrix: Matrix) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocationPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + + companion object { + + fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) + + fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) + + fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) + + fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + LicenseAllocationPrice(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) + + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) + + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) + + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) + + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: Unit): T + + fun visitTiered(tiered: Tiered): T + + fun visitBulk(bulk: Bulk): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: Package): T + + fun visitMatrix(matrix: Matrix): T + + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T + + fun visitTieredPackage(tieredPackage: TieredPackage): T + + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T + + fun visitGroupedTiered(groupedTiered: GroupedTiered): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ): T + + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T + + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T + + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: UnitWithProration): T + + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T + + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T + + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T + + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ): T + + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: MinimumComposite): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. + * + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") + } + } + + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + } + + return LicenseAllocationPrice(_json = json) + } + } + + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { + + override fun serialize( + value: LicenseAllocationPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + } + } + + class Unit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Unit]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Unit]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Unit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Unit = + Unit( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tiered = + Tiered( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tiered && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Bulk]. + * + * The following fields are required: + * ```kotlin + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Bulk]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Bulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Bulk = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Bulk && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Package]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (packageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Matrix]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (percent.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProration]. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class MinimumComposite @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10729,15 +142723,18 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10786,9 +142783,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10824,12 +142822,34 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10846,15 +142866,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11001,22 +143012,33 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [licenseAllocations]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations /** - * Returns the raw JSON value of [percentConfig]. + * Returns the raw JSON value of [minimumCompositeConfig]. * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("percent_config") + @JsonProperty("minimum_composite_config") @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [billableMetricId]. @@ -11176,27 +143198,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of [MinimumComposite]. * * The following fields are required: * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [MinimumComposite]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11219,27 +143244,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - licenseTypeId = percent.licenseTypeId - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -11266,13 +143294,60 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11292,21 +143367,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11651,7 +143711,7 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [MinimumComposite]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -11659,19 +143719,23 @@ private constructor( * ```kotlin * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): MinimumComposite = + MinimumComposite( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11692,20 +143756,21 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): MinimumComposite = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("minimum_composite")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -11740,9 +143805,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (minimumCompositeConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + - (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -11915,39 +143981,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * What percent of the component subtotals to charge + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [percent]. + * The currency of the license allocation. * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - fun _percent(): JsonField = percent + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11965,39 +144076,82 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .percent() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } fun additionalProperties(additionalProperties: Map) = apply { @@ -12022,32 +144176,37 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .percent() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - percent() + amount() + currency() + writeOffOverage() validated = true } @@ -12065,26 +144224,253 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } /** @@ -12201,12 +144587,13 @@ private constructor( return true } - return other is Percent && + return other is MinimumComposite && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12228,9 +144615,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12252,17 +144640,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12286,18 +144675,21 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12345,10 +144737,11 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12376,30 +144769,32 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12416,6 +144811,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12553,16 +144957,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -12571,6 +144965,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -12579,6 +144983,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -12737,27 +145151,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -12780,27 +145197,28 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - licenseTypeId = eventOutput.licenseTypeId - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -12815,21 +145233,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -12842,13 +145245,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12868,6 +145303,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13212,27 +145662,31 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13253,20 +145707,21 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -13300,10 +145755,11 @@ private constructor( */ internal fun validity(): Int = (cadence.asKnown()?.validity() ?: 0) + - (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -13476,87 +145932,309 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") + @JsonProperty("amount") @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * What percent of the component subtotals to charge * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - - /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun defaultUnitRate(): String? = - defaultUnitRate.getNullable("default_unit_rate") - - /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - - /** - * Returns the raw JSON value of [unitRatingKey]. - * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_rating_key") - @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey - - /** - * Returns the raw JSON value of [defaultUnitRate]. - * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_unit_rate") - @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun percent(): Double = percent.getRequired("percent") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [percent]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [percent], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("percent") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _percent(): JsonField = percent @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13574,84 +146252,39 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [PercentConfig]. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` */ fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [PercentConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var percent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } - - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) - - /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey - } - - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -13676,36 +146309,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -13723,36 +146352,26 @@ private constructor( * * Used for best match union deserialization. */ - internal fun validity(): Int = - (if (unitRatingKey.asKnown() == null) 0 else 1) + - (if (defaultUnitRate.asKnown() == null) 0 else 1) + - (if (groupingKey.asKnown() == null) 0 else 1) + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -13869,12 +146488,13 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -13895,10 +146515,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13920,1508 +146541,2019 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } - - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) - - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") - - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId - - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - */ - fun builder() = Builder() - } - - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { - - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } - - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) - - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = billableMetricId.getNullable("billable_metric_id") - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (adjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") - override fun hashCode(): Int = hashCode + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + invoiceGroupingKey.getNullable("invoice_grouping_key") - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_id") - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - companion object { + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - */ - fun builder() = Builder() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } - priceId() - planPhaseOrder() - validated = true - } + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (priceId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - companion object { + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - fun builder() = Builder() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Alias for calling [adjustment] with the following: - * ```kotlin - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(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( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - private var validated: Boolean = 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 metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (adjustment.asKnown()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown() == null) 0 else 1) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun percentageDiscount(): NewPercentageDiscount? = percentageDiscount + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun usageDiscount(): NewUsageDiscount? = usageDiscount + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun amountDiscount(): NewAmountDiscount? = amountDiscount + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun minimum(): NewMinimum? = minimum + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun maximum(): NewMaximum? = maximum + private var validated: Boolean = false - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun isUsageDiscount(): Boolean = usageDiscount != null + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } - fun isAmountDiscount(): Boolean = amountDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isMinimum(): Boolean = minimum != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) - fun isMaximum(): Boolean = maximum != null + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + companion object { - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + val ANNUAL = of("annual") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + val SEMI_ANNUAL = of("semi_annual") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + val MONTHLY = of("monthly") - fun _json(): JsonValue? = _json + val QUARTERLY = of("quarterly") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + val ONE_TIME = of("one_time") - private var validated: Boolean = false + val CUSTOM = of("custom") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + fun of(value: String) = Cadence(JsonField.of(value)) + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + known() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is Cadence && value == other.value } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - companion object { + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun toBuilder() = Builder().from(this) - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + companion object { - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } - fun visitMinimum(minimum: NewMinimum): T + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - fun visitMaximum(maximum: NewMaximum): T + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = json.asObject()?.get("adjustment_type")?.asString() + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) } - return Adjustment(_json = json) - } - } + private var validated: Boolean = false - internal class Serializer : BaseSerializer(Adjustment::class) { + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true } - } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun hashCode(): Int = hashCode + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun hashCode(): Int = hashCode - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Long? = planPhaseOrder.getNullable("plan_phase_order") + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Price? = price.getNullable("price") + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun toBuilder() = Builder().from(this) - fun toBuilder() = Builder().from(this) + companion object { - companion object { + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - */ - fun builder() = Builder() - } + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + amount() + currency() + writeOffOverage() + validated = true + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + companion object { - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewPlanMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + validated = true + } - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun hashCode(): Int = hashCode - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```kotlin - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - replacesPriceId() - allocationPrice()?.validate() - planPhaseOrder() - price()?.validate() - validated = true - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode(): Int = hashCode - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - internal fun validity(): Int = - (if (replacesPriceId.asKnown() == null) 0 else 1) + - (allocationPrice.asKnown()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown() == null) 0 else 1) + - (price.asKnown()?.validity() ?: 0) + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } /** New plan price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @@ -27301,6 +160433,7 @@ private constructor( return other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties @@ -27310,6 +160443,7 @@ private constructor( Objects.hash( replacesPriceId, allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties, @@ -27319,7 +160453,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index ed847a1a1..17348f964 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -76,7 +76,9 @@ import java.util.Objects * 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. + * cost basis with the number of credit units added. If you invoice or handle payment of credits + * outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the `invoice_settings` to + * `true` to prevent duplicate invoicing effects. * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and * `invoice_settings` must be included * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 698a9e59c..0cd7a32d9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -76,7 +76,9 @@ import java.util.Objects * 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. + * cost basis with the number of credit units added. If you invoice or handle payment of credits + * outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the `invoice_settings` to + * `true` to prevent duplicate invoicing effects. * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and * `invoice_settings` must be included * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index f85f65f2d..238cdaa74 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1166,6 +1166,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1176,11 +1177,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1190,6 +1194,15 @@ private constructor( */ fun allocationPrice(): NewAllocationPrice? = allocationPrice.getNullable("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): LicenseAllocationPrice? = + licenseAllocationPrice.getNullable("license_allocation_price") + /** * The phase to add this price to. * @@ -1216,6 +1229,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1255,12 +1278,14 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(price: Price) = apply { allocationPrice = price.allocationPrice + licenseAllocationPrice = price.licenseAllocationPrice planPhaseOrder = price.planPhaseOrder this.price = price.price additionalProperties = price.additionalProperties.toMutableMap() @@ -1281,6 +1306,324 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -1512,7 +1855,13 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Price = - Price(allocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap()) + Price( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1523,6 +1872,7 @@ private constructor( } allocationPrice()?.validate() + licenseAllocationPrice()?.validate() planPhaseOrder() price()?.validate() validated = true @@ -1544,115 +1894,111 @@ private constructor( */ internal fun validity(): Int = (allocationPrice.asKnown()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown()?.validity() ?: 0) + (if (planPhaseOrder.asKnown() == null) 0 else 1) + (price.asKnown()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = InnerPrice.Deserializer::class) - @JsonSerialize(using = InnerPrice.Serializer::class) - class InnerPrice + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { - fun unit(): NewPlanUnitPrice? = unit + fun unit(): Unit? = unit - fun tiered(): NewPlanTieredPrice? = tiered + fun tiered(): Tiered? = tiered - fun bulk(): NewPlanBulkPrice? = bulk + fun bulk(): Bulk? = bulk fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters - fun package_(): NewPlanPackagePrice? = package_ + fun package_(): Package? = package_ - fun matrix(): NewPlanMatrixPrice? = matrix + fun matrix(): Matrix? = matrix - fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + fun thresholdTotalAmount(): ThresholdTotalAmount? = thresholdTotalAmount - fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + fun tieredPackage(): TieredPackage? = tieredPackage - fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + fun tieredWithMinimum(): TieredWithMinimum? = tieredWithMinimum - fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + fun groupedTiered(): GroupedTiered? = groupedTiered - fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = - tieredPackageWithMinimum + fun tieredPackageWithMinimum(): TieredPackageWithMinimum? = tieredPackageWithMinimum - fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + fun packageWithAllocation(): PackageWithAllocation? = packageWithAllocation - fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + fun unitWithPercent(): UnitWithPercent? = unitWithPercent - fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + fun matrixWithAllocation(): MatrixWithAllocation? = matrixWithAllocation fun tieredWithProration(): TieredWithProration? = tieredWithProration - fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + fun unitWithProration(): UnitWithProration? = unitWithProration - fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + fun groupedAllocation(): GroupedAllocation? = groupedAllocation - fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + fun bulkWithProration(): BulkWithProration? = bulkWithProration - fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + fun groupedWithProratedMinimum(): GroupedWithProratedMinimum? = groupedWithProratedMinimum - fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = - groupedWithMeteredMinimum + fun groupedWithMeteredMinimum(): GroupedWithMeteredMinimum? = groupedWithMeteredMinimum fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = groupedWithMinMaxThresholds - fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + fun matrixWithDisplayName(): MatrixWithDisplayName? = matrixWithDisplayName - fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + fun groupedTieredPackage(): GroupedTieredPackage? = groupedTieredPackage - fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + fun maxGroupTieredPackage(): MaxGroupTieredPackage? = maxGroupTieredPackage - fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + fun scalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing? = scalableMatrixWithUnitPricing - fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + fun scalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing? = scalableMatrixWithTieredPricing - fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + fun cumulativeGroupedBulk(): CumulativeGroupedBulk? = cumulativeGroupedBulk fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = cumulativeGroupedAllocation - fun minimumComposite(): NewPlanMinimumCompositePrice? = minimumComposite + fun minimumComposite(): MinimumComposite? = minimumComposite fun percent(): Percent? = percent @@ -1721,85 +2067,82 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun asMinimumComposite(): NewPlanMinimumCompositePrice = + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -1863,22 +2206,22 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerPrice = apply { + fun validate(): LicenseAllocationPrice = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitTiered(tiered: NewPlanTieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -1886,54 +2229,50 @@ private constructor( bulkWithFilters.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { + override fun visitPackage(package_: Package) { package_.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) { matrixWithAllocation.validate() } @@ -1944,32 +2283,26 @@ private constructor( tieredWithProration.validate() } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } @@ -1981,38 +2314,37 @@ private constructor( } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -2023,9 +2355,7 @@ private constructor( cumulativeGroupedAllocation.validate() } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -2058,72 +2388,66 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = bulkWithFilters.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) = thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) = matrixWithAllocation.validity() override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitGroupedWithMinMaxThresholds( @@ -2131,37 +2455,35 @@ private constructor( ) = groupedWithMinMaxThresholds.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) = groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -2177,7 +2499,7 @@ private constructor( return true } - return other is InnerPrice && + return other is LicenseAllocationPrice && unit == other.unit && tiered == other.tiered && bulk == other.bulk && @@ -2248,501 +2570,493 @@ private constructor( override fun toString(): String = when { - unit != null -> "InnerPrice{unit=$unit}" - tiered != null -> "InnerPrice{tiered=$tiered}" - bulk != null -> "InnerPrice{bulk=$bulk}" - bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "InnerPrice{package_=$package_}" - matrix != null -> "InnerPrice{matrix=$matrix}" + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" thresholdTotalAmount != null -> - "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> - "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> - "InnerPrice{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> - "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> - "InnerPrice{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> - "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> - "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" groupedWithMinMaxThresholds != null -> - "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> - "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> - "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> - "InnerPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> - "InnerPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> - "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> - "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> - "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "InnerPrice{minimumComposite=$minimumComposite}" - percent != null -> "InnerPrice{percent=$percent}" - eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" - _json != null -> "InnerPrice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InnerPrice") + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } companion object { - fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) + fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) - fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) + fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) - fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - InnerPrice(bulkWithFilters = bulkWithFilters) + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) - fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) - fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - InnerPrice(thresholdTotalAmount = thresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - InnerPrice(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - InnerPrice(tieredWithMinimum = tieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - InnerPrice(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = InnerPrice(packageWithAllocation = packageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - InnerPrice(unitWithPercent = unitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - InnerPrice(matrixWithAllocation = matrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - InnerPrice(tieredWithProration = tieredWithProration) + LicenseAllocationPrice(tieredWithProration = tieredWithProration) - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - InnerPrice(unitWithProration = unitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - InnerPrice(groupedAllocation = groupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - InnerPrice(bulkWithProration = bulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - InnerPrice(groupedTieredPackage = groupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = InnerPrice(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = InnerPrice(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = InnerPrice(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) fun ofCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - InnerPrice(minimumComposite = minimumComposite) + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) - fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) - fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) } /** - * An interface that defines how to map each variant of [InnerPrice] to a value of type - * [T]. + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. */ interface Visitor { - fun visitUnit(unit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitTiered(tiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - fun visitPackage(package_: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T fun visitGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T fun visitEventOutput(eventOutput: EventOutput): T /** - * Maps an unknown variant of [InnerPrice] to a value of type [T]. + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. * - * An instance of [InnerPrice] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown InnerPrice: $json") + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") } } - internal class Deserializer : BaseDeserializer(InnerPrice::class) { + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { - override fun ObjectCodec.deserialize(node: JsonNode): InnerPrice { + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { val json = JsonValue.fromJsonNode(node) val modelType = json.asObject()?.get("model_type")?.asString() when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(unit = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(tiered = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulk = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_filters" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulkWithFilters = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(package_ = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(matrix = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(thresholdTotalAmount = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(groupedTiered = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(packageWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithPercent = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(bulkWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_allocation" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(minimumComposite = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "percent" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(percent = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(eventOutput = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } } - return InnerPrice(_json = json) + return LicenseAllocationPrice(_json = json) } } - internal class Serializer : BaseSerializer(InnerPrice::class) { + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { override fun serialize( - value: InnerPrice, + value: LicenseAllocationPrice, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -2801,19 +3115,20 @@ private constructor( value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InnerPrice") + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } } } - class BulkWithFilters + class Unit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val unitConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -2834,21 +3149,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -2895,11 +3213,12 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -2918,39 +3237,41 @@ private constructor( ) /** - * Configuration for bulk_with_filters pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -2967,6 +3288,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3094,17 +3424,6 @@ private constructor( */ fun referenceId(): String? = referenceId.getNullable("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -3123,6 +3442,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -3131,6 +3460,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3289,27 +3628,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") 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 = @@ -3332,45 +3674,30 @@ private constructor( private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - licenseTypeId = bulkWithFilters.licenseTypeId - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3395,13 +3722,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```kotlin - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3421,6 +3780,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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. @@ -3765,27 +4138,31 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```kotlin - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("unitConfig", unitConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3806,20 +4183,21 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): Unit = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("unit")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + unitConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration()?.validate() @@ -3852,11 +4230,12 @@ private constructor( * Used for best match union deserialization. */ internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + - (cadence.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + (if (itemId.asKnown() == null) 0 else 1) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown() == null) 0 else 1) + + (unitConfig.asKnown()?.validity() ?: 0) + (if (billableMetricId.asKnown() == null) 0 else 1) + (if (billedInAdvance.asKnown() == null) 0 else 1) + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + @@ -3872,62 +4251,241 @@ private constructor( (metadata.asKnown()?.validity() ?: 0) + (if (referenceId.asKnown() == null) 0 else 1) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Property filters to apply (all must match) + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun filters(): List = filters.getRequired("filters") + fun amount(): String = amount.getRequired("amount") /** - * Bulk tiers for rating based on total usage volume + * The currency of the license allocation. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun currency(): String = currency.getRequired("currency") /** - * Returns the raw JSON value of [filters]. + * When True, overage beyond the allocation is written off. * - * Unlike [filters], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - fun _filters(): JsonField> = filters + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [currency]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") + @JsonProperty("currency") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3945,84 +4503,66090 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```kotlin - * .filters() - * .tiers() + * .amount() + * .currency() * ``` */ fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var filters: JsonField>? = null - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Adds a single [Filter] to [filters]. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tiered = + Tiered( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tiered && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Bulk]. + * + * The following fields are required: + * ```kotlin + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Bulk]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Bulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Bulk = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Bulk && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (filters.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (propertyKey.asKnown() == null) 0 else 1) + + (if (propertyValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Package]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (packageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Matrix]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (thresholdTotalAmountConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (consumptionTable.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ConsumptionTable]. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (threshold.asKnown() == null) 0 else 1) + + (if (totalAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Boolean? = + hideZeroAmountTiers.getNullable("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTiered]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredPackageWithMinimumConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (packageWithAllocationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (packageAmount.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithPercentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (percent.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (tieredWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProration]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (unitWithProrationConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (allocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (overageUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProration]. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithProrationConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): String? = + tierLowerBound.getNullable("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitAmount.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimum.asKnown() == null) 0 else 1) + + (if (unitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (minimumUnitAmount.asKnown() == null) 0 else 1) + + (if (pricingKey.asKnown() == null) 0 else 1) + + (scalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (scalingValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (pricingValue.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (maximumCharge.asKnown() == null) 0 else 1) + + (if (minimumCharge.asKnown() == null) 0 else 1) + + (if (perUnitRate.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimension.asKnown() == null) 0 else 1) + + (unitAmounts.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitAmount]. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (dimensionValue.asKnown() == null) 0 else 1) + + (if (displayName.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (perUnit.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (packageSize.asKnown() == null) 0 else 1) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithUnitPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Boolean? = prorate.getNullable("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (unitPrice.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (prorate.asKnown() == null) 0 else 1) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (scalableMatrixWithTieredPricingConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): String? = secondDimension.getNullable("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimension.asKnown() == null) 0 else 1) + + (matrixScalingFactors.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown() == null) 0 else 1) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): String? = + secondDimensionValue.getNullable("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (firstDimensionValue.asKnown() == null) 0 else 1) + + (if (scalingFactor.asKnown() == null) 0 else 1) + + (if (secondDimensionValue.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (dimensionValues.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown() == null) 0 else 1) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DimensionValue]. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```kotlin + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (tierLowerBound.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown() == null) 0 else 1) + + (if (groupAllocation.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + (if (unitAmount.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("minimum_composite") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [minimumCompositeConfig]. + * + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_composite_config") + @ExcludeMissing + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumComposite]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumComposite]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("minimum_composite") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumComposite]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumComposite = + MinimumComposite( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumComposite = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum_composite")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (minimumCompositeConfig.asKnown()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Boolean? = prorated.getNullable("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (minimumAmount.asKnown() == null) 0 else 1) + + (if (prorated.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumComposite && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (percentConfig.asKnown()?.validity() ?: 0) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (percent.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (cadence.asKnown()?.validity() ?: 0) + + (eventOutputConfig.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + (licenseAllocations.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + val ANNUAL = of("annual") + + val SEMI_ANNUAL = of("semi_annual") + + val MONTHLY = of("monthly") + + val QUARTERLY = of("quarterly") + + val ONE_TIME = of("one_time") + + val CUSTOM = of("custom") + + fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString() + ?: throw OrbInvalidDataException("Value is not a String") + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): String? = + defaultUnitRate.getNullable("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String? = groupingKey.getNullable("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (unitRatingKey.asKnown() == null) 0 else 1) + + (if (defaultUnitRate.asKnown() == null) 0 else 1) + + (if (groupingKey.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Boolean? = + writeOffOverage.getNullable("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (if (amount.asKnown() == null) 0 else 1) + + (if (currency.asKnown() == null) 0 else 1) + + (if (writeOffOverage.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + /** New plan price request body params. */ + @JsonDeserialize(using = InnerPrice.Deserializer::class) + @JsonSerialize(using = InnerPrice.Serializer::class) + class InnerPrice + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): NewPlanUnitPrice? = unit + + fun tiered(): NewPlanTieredPrice? = tiered + + fun bulk(): NewPlanBulkPrice? = bulk + + fun bulkWithFilters(): BulkWithFilters? = bulkWithFilters + + fun package_(): NewPlanPackagePrice? = package_ + + fun matrix(): NewPlanMatrixPrice? = matrix + + fun thresholdTotalAmount(): NewPlanThresholdTotalAmountPrice? = thresholdTotalAmount + + fun tieredPackage(): NewPlanTieredPackagePrice? = tieredPackage + + fun tieredWithMinimum(): NewPlanTieredWithMinimumPrice? = tieredWithMinimum + + fun groupedTiered(): NewPlanGroupedTieredPrice? = groupedTiered + + fun tieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice? = + tieredPackageWithMinimum + + fun packageWithAllocation(): NewPlanPackageWithAllocationPrice? = packageWithAllocation + + fun unitWithPercent(): NewPlanUnitWithPercentPrice? = unitWithPercent + + fun matrixWithAllocation(): NewPlanMatrixWithAllocationPrice? = matrixWithAllocation + + fun tieredWithProration(): TieredWithProration? = tieredWithProration + + fun unitWithProration(): NewPlanUnitWithProrationPrice? = unitWithProration + + fun groupedAllocation(): NewPlanGroupedAllocationPrice? = groupedAllocation + + fun bulkWithProration(): NewPlanBulkWithProrationPrice? = bulkWithProration + + fun groupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice? = + groupedWithProratedMinimum + + fun groupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice? = + groupedWithMeteredMinimum + + fun groupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds? = + groupedWithMinMaxThresholds + + fun matrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice? = matrixWithDisplayName + + fun groupedTieredPackage(): NewPlanGroupedTieredPackagePrice? = groupedTieredPackage + + fun maxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice? = maxGroupTieredPackage + + fun scalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice? = + scalableMatrixWithUnitPricing + + fun scalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice? = + scalableMatrixWithTieredPricing + + fun cumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice? = cumulativeGroupedBulk + + fun cumulativeGroupedAllocation(): CumulativeGroupedAllocation? = + cumulativeGroupedAllocation + + fun minimumComposite(): NewPlanMinimumCompositePrice? = minimumComposite + + fun percent(): Percent? = percent + + fun eventOutput(): EventOutput? = eventOutput + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): JsonValue? = _json + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): InnerPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "InnerPrice{unit=$unit}" + tiered != null -> "InnerPrice{tiered=$tiered}" + bulk != null -> "InnerPrice{bulk=$bulk}" + bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "InnerPrice{package_=$package_}" + matrix != null -> "InnerPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "InnerPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "InnerPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "InnerPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "InnerPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> "InnerPrice{minimumComposite=$minimumComposite}" + percent != null -> "InnerPrice{percent=$percent}" + eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" + _json != null -> "InnerPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InnerPrice") + } + + companion object { + + fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) + + fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) + + fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + InnerPrice(bulkWithFilters = bulkWithFilters) + + fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + + fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + InnerPrice(thresholdTotalAmount = thresholdTotalAmount) + + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + InnerPrice(tieredPackage = tieredPackage) + + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + InnerPrice(tieredWithMinimum = tieredWithMinimum) + + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + InnerPrice(groupedTiered = groupedTiered) + + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = InnerPrice(packageWithAllocation = packageWithAllocation) + + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + InnerPrice(unitWithPercent = unitWithPercent) + + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + InnerPrice(matrixWithAllocation = matrixWithAllocation) + + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + InnerPrice(tieredWithProration = tieredWithProration) + + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + InnerPrice(unitWithProration = unitWithProration) + + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + InnerPrice(groupedAllocation = groupedAllocation) + + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + InnerPrice(bulkWithProration = bulkWithProration) + + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) + + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + InnerPrice(groupedTieredPackage = groupedTieredPackage) + + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = InnerPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = InnerPrice(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = InnerPrice(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + InnerPrice(minimumComposite = minimumComposite) + + fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + + fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [InnerPrice] to a value of type + * [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [InnerPrice] to a value of type [T]. + * + * An instance of [InnerPrice] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown InnerPrice: $json") + } + } + + internal class Deserializer : BaseDeserializer(InnerPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InnerPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject()?.get("model_type")?.asString() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(unit = it, _json = json) + } ?: InnerPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(tiered = it, _json = json) + } ?: InnerPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulk = it, _json = json) + } ?: InnerPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulkWithFilters = it, _json = json) + } ?: InnerPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(package_ = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(matrix = it, _json = json) + } ?: InnerPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(thresholdTotalAmount = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(groupedTiered = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(packageWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithPercent = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(bulkWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } + ?: InnerPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(minimumComposite = it, _json = json) } + ?: InnerPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(percent = it, _json = json) + } ?: InnerPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(eventOutput = it, _json = json) + } ?: InnerPrice(_json = json) + } + } + + return InnerPrice(_json = json) + } + } + + internal class Serializer : BaseSerializer(InnerPrice::class) { + + override fun serialize( + value: InnerPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InnerPrice") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): String? = 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Boolean? = billedInAdvance.getNullable("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): NewBillingCycleConfiguration? = + billingCycleConfiguration.getNullable("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Double? = conversionRate.getNullable("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): ConversionRateConfig? = + conversionRateConfig.getNullable("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): String? = currency.getNullable("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): NewDimensionalPriceConfiguration? = + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): String? = externalPriceId.getNullable("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Double? = + fixedPriceQuantity.getNullable("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = + 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. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): NewBillingCycleConfiguration? = + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): String? = licenseTypeId.getNullable("license_type_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`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Metadata? = metadata.getNullable("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): String? = referenceId.getNullable("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + 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 conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + 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 licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```kotlin + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + 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?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```kotlin + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + 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: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can 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?) = metadata(JsonField.ofNullable(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + 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?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration()?.validate() + conversionRate() + conversionRateConfig()?.validate() + currency() + dimensionalPriceConfiguration()?.validate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration()?.validate() + licenseTypeId() + metadata()?.validate() + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown()?.validity() ?: 0) + + (cadence.asKnown()?.validity() ?: 0) + + (if (itemId.asKnown() == null) 0 else 1) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown() == null) 0 else 1) + + (if (billableMetricId.asKnown() == null) 0 else 1) + + (if (billedInAdvance.asKnown() == null) 0 else 1) + + (billingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (conversionRate.asKnown() == null) 0 else 1) + + (conversionRateConfig.asKnown()?.validity() ?: 0) + + (if (currency.asKnown() == null) 0 else 1) + + (dimensionalPriceConfiguration.asKnown()?.validity() ?: 0) + + (if (externalPriceId.asKnown() == null) 0 else 1) + + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + + (if (licenseTypeId.asKnown() == null) 0 else 1) + + (metadata.asKnown()?.validity() ?: 0) + + (if (referenceId.asKnown() == null) 0 else 1) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```kotlin + * .filters() + * .tiers() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -13429,19 +79993,26 @@ private constructor( return other is Price && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Price{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "Price{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } class Adjustment diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index 20e1e7b77..63020f132 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -166,7 +166,9 @@ interface LedgerServiceAsync { * 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. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and * `invoice_settings` must be included * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required @@ -282,7 +284,9 @@ interface LedgerServiceAsync { * 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. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and * `invoice_settings` must be included * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index 74bfa5c1f..370f9a682 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -163,7 +163,9 @@ interface LedgerService { * 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. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and * `invoice_settings` must be included * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required @@ -279,7 +281,9 @@ interface LedgerService { * 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. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and * `invoice_settings` must be included * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 2aabdd88e..9111abe07 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -67,6 +67,72 @@ internal class BetaCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -190,6 +256,73 @@ internal class BetaCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -318,6 +451,75 @@ internal class BetaCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -443,6 +645,78 @@ internal class BetaCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -562,6 +836,72 @@ internal class BetaCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -689,6 +1029,73 @@ internal class BetaCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index d573e52d0..a500b8fbb 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -67,6 +67,80 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -190,6 +264,81 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -322,6 +471,83 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -447,6 +673,83 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -566,6 +869,80 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -693,6 +1070,81 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index e36d40f19..16c24ee58 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -39,6 +39,68 @@ internal class PlanCreateParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -174,6 +236,72 @@ internal class PlanCreateParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -309,6 +437,68 @@ internal class PlanCreateParamsTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 9c1c15f50..8f47c6321 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -92,6 +92,82 @@ internal class BetaServiceAsyncTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -223,6 +299,85 @@ internal class BetaServiceAsyncTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index b84a4af74..c25a8587c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -61,6 +61,76 @@ internal class PlanServiceAsyncTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index c3514f8f5..f574aacac 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -92,6 +92,87 @@ internal class ExternalPlanIdServiceAsyncTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -223,6 +304,87 @@ internal class ExternalPlanIdServiceAsyncTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 4cd03a79c..e8df9de9e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -92,6 +92,82 @@ internal class BetaServiceTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -223,6 +299,85 @@ internal class BetaServiceTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index f8787dff0..afc6d6962 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -61,6 +61,76 @@ internal class PlanServiceTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index 5ec00a8bc..07969a8ea 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -92,6 +92,87 @@ internal class ExternalPlanIdServiceTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -223,6 +304,87 @@ internal class ExternalPlanIdServiceTest { .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() From 860ce4a58b2d43cad76f218d23db8baccab57534 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:30:58 +0000 Subject: [PATCH 23/52] fix: fix request delays for retrying to be more respectful of high requested delays --- .../com/withorb/api/core/http/RetryingHttpClient.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index bebc6c5f9..40a35dd50 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -197,13 +197,8 @@ private constructor( } } ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } + // If the API asks us to wait a certain amount of time, do what it says. + return Duration.ofNanos(retryAfterNanos.toLong()) } // Apply exponential backoff, but not more than the max. From 8195969d6833b6dbf576fe9a74e511ce8d1b4a00 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:51:20 +0000 Subject: [PATCH 24/52] chore(internal): bump palantir-java-format --- buildSrc/src/main/kotlin/orb.java.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/orb.java.gradle.kts b/buildSrc/src/main/kotlin/orb.java.gradle.kts index 70fc33f41..8f4f902a6 100644 --- a/buildSrc/src/main/kotlin/orb.java.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.java.gradle.kts @@ -45,7 +45,7 @@ tasks.withType().configureEach { val palantir by configurations.creating dependencies { - palantir("com.palantir.javaformat:palantir-java-format:2.73.0") + palantir("com.palantir.javaformat:palantir-java-format:2.89.0") } fun registerPalantir( From e2497db0a8bb5068d55a5ed257ebbad1e766bf2c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:49:44 +0000 Subject: [PATCH 25/52] chore(test): do not count install time for mock server timeout --- scripts/mock | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/mock b/scripts/mock index 0b28f6ea2..bcf3b392b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - # Wait for server to come online + # Wait for server to come online (max 30s) echo -n "Waiting for server" + attempts=0 while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Prism server to start" + cat .prism.log + exit 1 + fi echo -n "." sleep 0.1 done From e3974536b461231fef00e23c9e02fe6b274b6bd1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:24:43 +0000 Subject: [PATCH 26/52] feat(api): api update --- .stats.yml | 4 +-- .../CustomerUpdateByExternalIdParams.kt | 20 +++++++++------ .../api/models/CustomerUpdateParams.kt | 25 +++++++++++-------- .../services/async/CustomerServiceAsync.kt | 5 ++-- .../api/services/blocking/CustomerService.kt | 5 ++-- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/.stats.yml b/.stats.yml index 95afb0ace..e3a4be03b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-dafe9f726a47bdf7e506af8f10c6abcf4321dcc58106ce2b806a918778dfe2be.yml -openapi_spec_hash: 8e9827f2e8818d011e6afb203adb825f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-87e16688d40cde735bc36efd40d8c12a7918919b18268d9c40b46d0cdf2f6251.yml +openapi_spec_hash: 83f1f5a6fa7a07db4af09426232d0786 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 28fe5c9c7..079097c94 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -91,8 +91,9 @@ private constructor( fun billingAddress(): AddressInput? = 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only be + * set if the customer does not already have a currency configured. If not set at creation or + * update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -656,8 +657,9 @@ private constructor( } /** - * 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = apply { body.currency(currency) } @@ -1420,8 +1422,9 @@ private constructor( fun billingAddress(): AddressInput? = 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -2037,8 +2040,9 @@ private constructor( } /** - * 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can + * only be set if the customer does not already have a currency configured. If not set + * at creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index b5e9ab2f4..e97b351d9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -34,8 +34,9 @@ import java.util.Objects /** * 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. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` can + * only be set if it has not already been set on the customer. Other fields on a customer are + * currently immutable. */ class CustomerUpdateParams private constructor( @@ -92,8 +93,9 @@ private constructor( fun billingAddress(): AddressInput? = 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only be + * set if the customer does not already have a currency configured. If not set at creation or + * update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -652,8 +654,9 @@ private constructor( } /** - * 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = apply { body.currency(currency) } @@ -1416,8 +1419,9 @@ private constructor( fun billingAddress(): AddressInput? = 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -2033,8 +2037,9 @@ private constructor( } /** - * 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. + * An ISO 4217 currency string used for the customer's invoices and balance. This can + * only be set if the customer does not already have a currency configured. If not set + * at creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt index 7cbad07db..26cf3e09c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt @@ -121,8 +121,9 @@ interface CustomerServiceAsync { /** * 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. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` + * can only be set if it has not already been set on the customer. Other fields on a customer + * are currently immutable. */ suspend fun update( customerId: String, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt index d4cc6f1b9..0ca4c547f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt @@ -121,8 +121,9 @@ interface CustomerService { /** * 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. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` + * can only be set if it has not already been set on the customer. Other fields on a customer + * are currently immutable. */ fun update( customerId: String, From 0e05662b947ceb6d28995075cc59fad024d6161f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 7 Mar 2026 00:22:59 +0000 Subject: [PATCH 27/52] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Alert.kt | 62 +++++- .../AlertCreateForSubscriptionParams.kt | 185 +++++++++++++++++- .../AlertCreateForSubscriptionParamsTest.kt | 6 + .../api/models/AlertListPageResponseTest.kt | 3 + .../com/withorb/api/models/AlertTest.kt | 3 + .../services/async/AlertServiceAsyncTest.kt | 2 + .../api/services/blocking/AlertServiceTest.kt | 2 + 8 files changed, 260 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index e3a4be03b..438843fd3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-87e16688d40cde735bc36efd40d8c12a7918919b18268d9c40b46d0cdf2f6251.yml -openapi_spec_hash: 83f1f5a6fa7a07db4af09426232d0786 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d6a851f21804170f796637f1911c3382f1c57f5ed6b9b77cd7d0c6f74c06e174.yml +openapi_spec_hash: 82df33badf54d0c7087a61145d379f58 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt index 971031581..9f491ff07 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -39,6 +39,7 @@ private constructor( private val thresholds: JsonField>, private val type: JsonField, private val balanceAlertStatus: JsonField>, + private val groupingKeys: JsonField>, private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -66,6 +67,9 @@ private constructor( @JsonProperty("balance_alert_status") @ExcludeMissing balanceAlertStatus: JsonField> = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + groupingKeys: JsonField> = JsonMissing.of(), @JsonProperty("license_type") @ExcludeMissing licenseType: JsonField = JsonMissing.of(), @@ -81,6 +85,7 @@ private constructor( thresholds, type, balanceAlertStatus, + groupingKeys, licenseType, mutableMapOf(), ) @@ -174,6 +179,15 @@ private constructor( fun balanceAlertStatus(): List? = balanceAlertStatus.getNullable("balance_alert_status") + /** + * The property keys to group cost alerts by. Only present for cost alerts with grouping + * enabled. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") + /** * Minified license type for alert serialization. * @@ -270,6 +284,15 @@ private constructor( @ExcludeMissing fun _balanceAlertStatus(): JsonField> = balanceAlertStatus + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_keys") + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys + /** * Returns the raw JSON value of [licenseType]. * @@ -327,6 +350,7 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null private var balanceAlertStatus: JsonField>? = null + private var groupingKeys: JsonField>? = null private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -342,6 +366,7 @@ private constructor( thresholds = alert.thresholds.map { it.toMutableList() } type = alert.type balanceAlertStatus = alert.balanceAlertStatus.map { it.toMutableList() } + groupingKeys = alert.groupingKeys.map { it.toMutableList() } licenseType = alert.licenseType additionalProperties = alert.additionalProperties.toMutableMap() } @@ -506,6 +531,36 @@ private constructor( } } + /** + * The property keys to group cost alerts by. Only present for cost alerts with grouping + * enabled. + */ + fun groupingKeys(groupingKeys: List?) = + groupingKeys(JsonField.ofNullable(groupingKeys)) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) + } + } + /** Minified license type for alert serialization. */ fun licenseType(licenseType: LicenseType?) = licenseType(JsonField.ofNullable(licenseType)) @@ -573,6 +628,7 @@ private constructor( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), (balanceAlertStatus ?: JsonMissing.of()).map { it.toImmutable() }, + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, licenseType, additionalProperties.toMutableMap(), ) @@ -596,6 +652,7 @@ private constructor( thresholds()?.forEach { it.validate() } type().validate() balanceAlertStatus()?.forEach { it.validate() } + groupingKeys() licenseType()?.validate() validated = true } @@ -625,6 +682,7 @@ private constructor( (thresholds.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown()?.validity() ?: 0) + (balanceAlertStatus.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + + (groupingKeys.asKnown()?.size ?: 0) + (licenseType.asKnown()?.validity() ?: 0) /** The metric the alert applies to. */ @@ -1590,6 +1648,7 @@ private constructor( thresholds == other.thresholds && type == other.type && balanceAlertStatus == other.balanceAlertStatus && + groupingKeys == other.groupingKeys && licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -1607,6 +1666,7 @@ private constructor( thresholds, type, balanceAlertStatus, + groupingKeys, licenseType, additionalProperties, ) @@ -1615,5 +1675,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, groupingKeys=$groupingKeys, licenseType=$licenseType, additionalProperties=$additionalProperties}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index d0130f701..3b606a191 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -59,6 +59,14 @@ private constructor( */ fun type(): Type = body.type() + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun groupingKeys(): List? = body.groupingKeys() + /** * The metric to track usage for. * @@ -67,6 +75,14 @@ private constructor( */ fun metricId(): String? = body.metricId() + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pricingUnitId(): String? = body.pricingUnitId() + /** * Returns the raw JSON value of [thresholds]. * @@ -81,6 +97,13 @@ private constructor( */ fun _type(): JsonField = body._type() + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupingKeys(): JsonField> = body._groupingKeys() + /** * Returns the raw JSON value of [metricId]. * @@ -88,6 +111,13 @@ private constructor( */ fun _metricId(): JsonField = body._metricId() + /** + * Returns the raw JSON value of [pricingUnitId]. + * + * Unlike [pricingUnitId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _pricingUnitId(): JsonField = body._pricingUnitId() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -139,7 +169,10 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [thresholds] * - [type] + * - [groupingKeys] * - [metricId] + * - [pricingUnitId] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -175,6 +208,27 @@ private constructor( */ fun type(type: JsonField) = apply { body.type(type) } + /** The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. */ + fun groupingKeys(groupingKeys: List?) = apply { body.groupingKeys(groupingKeys) } + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + body.groupingKeys(groupingKeys) + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + /** The metric to track usage for. */ fun metricId(metricId: String?) = apply { body.metricId(metricId) } @@ -186,6 +240,20 @@ private constructor( */ fun metricId(metricId: JsonField) = apply { body.metricId(metricId) } + /** The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. */ + fun pricingUnitId(pricingUnitId: String?) = apply { body.pricingUnitId(pricingUnitId) } + + /** + * Sets [Builder.pricingUnitId] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pricingUnitId(pricingUnitId: JsonField) = apply { + body.pricingUnitId(pricingUnitId) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -342,7 +410,9 @@ private constructor( private constructor( private val thresholds: JsonField>, private val type: JsonField, + private val groupingKeys: JsonField>, private val metricId: JsonField, + private val pricingUnitId: JsonField, private val additionalProperties: MutableMap, ) { @@ -352,10 +422,16 @@ private constructor( @ExcludeMissing thresholds: JsonField> = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + groupingKeys: JsonField> = JsonMissing.of(), @JsonProperty("metric_id") @ExcludeMissing metricId: JsonField = JsonMissing.of(), - ) : this(thresholds, type, metricId, mutableMapOf()) + @JsonProperty("pricing_unit_id") + @ExcludeMissing + pricingUnitId: JsonField = JsonMissing.of(), + ) : this(thresholds, type, groupingKeys, metricId, pricingUnitId, mutableMapOf()) /** * The thresholds that define the values at which the alert will be triggered. @@ -373,6 +449,14 @@ private constructor( */ fun type(): Type = type.getRequired("type") + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKeys(): List? = groupingKeys.getNullable("grouping_keys") + /** * The metric to track usage for. * @@ -381,6 +465,14 @@ private constructor( */ fun metricId(): String? = metricId.getNullable("metric_id") + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pricingUnitId(): String? = pricingUnitId.getNullable("pricing_unit_id") + /** * Returns the raw JSON value of [thresholds]. * @@ -397,6 +489,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_keys") + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys + /** * Returns the raw JSON value of [metricId]. * @@ -404,6 +506,16 @@ private constructor( */ @JsonProperty("metric_id") @ExcludeMissing fun _metricId(): JsonField = metricId + /** + * Returns the raw JSON value of [pricingUnitId]. + * + * Unlike [pricingUnitId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_unit_id") + @ExcludeMissing + fun _pricingUnitId(): JsonField = pricingUnitId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -435,13 +547,17 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null + private var groupingKeys: JsonField>? = null private var metricId: JsonField = JsonMissing.of() + private var pricingUnitId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(body: Body) = apply { thresholds = body.thresholds.map { it.toMutableList() } type = body.type + groupingKeys = body.groupingKeys.map { it.toMutableList() } metricId = body.metricId + pricingUnitId = body.pricingUnitId additionalProperties = body.additionalProperties.toMutableMap() } @@ -483,6 +599,35 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + */ + fun groupingKeys(groupingKeys: List?) = + groupingKeys(JsonField.ofNullable(groupingKeys)) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) + } + } + /** The metric to track usage for. */ fun metricId(metricId: String?) = metricId(JsonField.ofNullable(metricId)) @@ -495,6 +640,23 @@ private constructor( */ fun metricId(metricId: JsonField) = apply { this.metricId = metricId } + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + */ + fun pricingUnitId(pricingUnitId: String?) = + pricingUnitId(JsonField.ofNullable(pricingUnitId)) + + /** + * Sets [Builder.pricingUnitId] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnitId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnitId(pricingUnitId: JsonField) = apply { + this.pricingUnitId = pricingUnitId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -531,7 +693,9 @@ private constructor( Body( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, metricId, + pricingUnitId, additionalProperties.toMutableMap(), ) } @@ -545,7 +709,9 @@ private constructor( thresholds().forEach { it.validate() } type().validate() + groupingKeys() metricId() + pricingUnitId() validated = true } @@ -566,7 +732,9 @@ private constructor( internal fun validity(): Int = (thresholds.asKnown()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown()?.validity() ?: 0) + - (if (metricId.asKnown() == null) 0 else 1) + (groupingKeys.asKnown()?.size ?: 0) + + (if (metricId.asKnown() == null) 0 else 1) + + (if (pricingUnitId.asKnown() == null) 0 else 1) override fun equals(other: Any?): Boolean { if (this === other) { @@ -576,18 +744,27 @@ private constructor( return other is Body && thresholds == other.thresholds && type == other.type && + groupingKeys == other.groupingKeys && metricId == other.metricId && + pricingUnitId == other.pricingUnitId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(thresholds, type, metricId, additionalProperties) + Objects.hash( + thresholds, + type, + groupingKeys, + metricId, + pricingUnitId, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{thresholds=$thresholds, type=$type, metricId=$metricId, additionalProperties=$additionalProperties}" + "Body{thresholds=$thresholds, type=$type, groupingKeys=$groupingKeys, metricId=$metricId, pricingUnitId=$pricingUnitId, additionalProperties=$additionalProperties}" } /** The type of alert to create. This must be a valid alert type. */ diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt index fd9d85cc7..ee5bbff45 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt @@ -13,7 +13,9 @@ internal class AlertCreateForSubscriptionParamsTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() } @@ -38,14 +40,18 @@ internal class AlertCreateForSubscriptionParamsTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() val body = params._body() assertThat(body.thresholds()).containsExactly(Threshold.builder().value(0.0).build()) assertThat(body.type()).isEqualTo(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + assertThat(body.groupingKeys()).containsExactly("string") assertThat(body.metricId()).isEqualTo("metric_id") + assertThat(body.pricingUnitId()).isEqualTo("pricing_unit_id") } @Test diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt index 39344d63e..6d9d31146 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt @@ -44,6 +44,7 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .addGroupingKey("string") .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) @@ -80,6 +81,7 @@ internal class AlertListPageResponseTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) @@ -122,6 +124,7 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .addGroupingKey("string") .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt index c38fa163b..f3bd200b9 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt @@ -39,6 +39,7 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") .licenseType(Alert.LicenseType.builder().id("id").build()) .build() @@ -71,6 +72,7 @@ internal class AlertTest { .containsExactly( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + assertThat(alert.groupingKeys()).containsExactly("string") assertThat(alert.licenseType()).isEqualTo(Alert.LicenseType.builder().id("id").build()) } @@ -104,6 +106,7 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") .licenseType(Alert.LicenseType.builder().id("id").build()) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt index 2de44858e..00399c5fd 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt @@ -126,7 +126,9 @@ internal class AlertServiceAsyncTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt index 9ab70abdb..a00d25b96 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt @@ -126,7 +126,9 @@ internal class AlertServiceTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() ) From 3c13033d0e362da84b28e1b5e26ba32d69188bac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:20:42 +0000 Subject: [PATCH 28/52] fix(client): incorrect `Retry-After` parsing --- .../api/core/http/RetryingHttpClient.kt | 2 +- .../api/core/http/RetryingHttpClientTest.kt | 221 +++++++++++++++--- 2 files changed, 191 insertions(+), 32 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index 40a35dd50..460994105 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -184,7 +184,7 @@ private constructor( ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { - ChronoUnit.MILLIS.between( + ChronoUnit.NANOS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index ebe67c78b..2ec15348b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -20,7 +20,11 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.Sleeper import com.withorb.api.errors.OrbRetryableException import java.io.InputStream +import java.time.Clock import java.time.Duration +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -36,6 +40,20 @@ internal class RetryingHttpClientTest { private lateinit var baseUrl: String private lateinit var httpClient: HttpClient + private class RecordingSleeper : Sleeper { + val durations = mutableListOf() + + override fun sleep(duration: Duration) { + durations.add(duration) + } + + override suspend fun sleepAsync(duration: Duration) { + durations.add(duration) + } + + override fun close() {} + } + @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { baseUrl = wmRuntimeInfo.httpBaseUrl @@ -85,7 +103,8 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = retryingHttpClientBuilder().build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).build() val response = retryingClient.execute( @@ -99,6 +118,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @@ -110,8 +130,12 @@ internal class RetryingHttpClientTest { .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) + val sleeper = RecordingSleeper() val retryingClient = - retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + retryingHttpClientBuilder(sleeper) + .maxRetries(2) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute( @@ -125,20 +149,20 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withRetryAfterHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) // First we fail with a retry after header given as a date .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -157,7 +181,13 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + // Fix the clock to 5 seconds before the Retry-After date so the date-based backoff is + // deterministic. + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -185,19 +215,20 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertThat(sleeper.durations) + .containsExactly(Duration.ofSeconds(5), Duration.ofMillis(1234)) assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -207,7 +238,11 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -226,6 +261,7 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertThat(sleeper.durations).containsExactly(Duration.ofSeconds(5)) assertNoResponseLeaks() } @@ -246,7 +282,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() val response = retryingClient.execute( @@ -260,6 +297,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(10)) assertNoResponseLeaks() } @@ -296,20 +334,12 @@ internal class RetryingHttpClientTest { override fun close() = httpClient.close() } + val sleeper = RecordingSleeper() val retryingClient = RetryingHttpClient.builder() .httpClient(failingHttpClient) .maxRetries(2) - .sleeper( - object : Sleeper { - - override fun sleep(duration: Duration) {} - - override suspend fun sleepAsync(duration: Duration) {} - - override fun close() {} - } - ) + .sleeper(sleeper) .build() val response = @@ -333,24 +363,153 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("0")), ) + // Exponential backoff with jitter: 0.5s * jitter where jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) assertNoResponseLeaks() } - private fun retryingHttpClientBuilder() = - RetryingHttpClient.builder() - .httpClient(httpClient) - // Use a no-op `Sleeper` to make the test fast. - .sleeper( - object : Sleeper { + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoff(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(3).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) - override fun sleep(duration: Duration) {} + // All retries exhausted; the last 503 response is returned. + assertThat(response.statusCode()).isEqualTo(503) + verify(4, postRequestedFor(urlPathEqualTo("/something"))) + // Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 8) * jitter where + // jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(3) + // retries=1: 0.5s * [0.75, 1.0] + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + // retries=2: 1.0s * [0.75, 1.0] + assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) + // retries=3: 2.0s * [0.75, 1.0] + assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) + assertNoResponseLeaks() + } - override suspend fun sleepAsync(duration: Duration) {} + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoffCap(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(6).build() - override fun close() {} - } + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, ) + assertThat(response.statusCode()).isEqualTo(503) + verify(7, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).hasSize(6) + // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsPriorityOverRetryAfter(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable() + .withHeader("Retry-After-Ms", "50") + .withHeader("Retry-After", "2") + ) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Retry-After-Ms (50ms) takes priority over Retry-After (2s). + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(50)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterUnparseable(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After", "not-a-date-or-number")) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Unparseable Retry-After falls through to exponential backoff. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder( + sleeper: RecordingSleeper, + clock: Clock = Clock.systemUTC(), + ) = RetryingHttpClient.builder().httpClient(httpClient).sleeper(sleeper).clock(clock) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) runBlocking { executeAsync(request) } else execute(request) From 7091a7208d02be59e8e72fcec879ca805cf00813 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 00:31:08 +0000 Subject: [PATCH 29/52] feat(api): api update --- .stats.yml | 4 ++-- .../main/kotlin/com/withorb/api/models/Customer.kt | 12 ++++++++++++ .../com/withorb/api/models/CustomerCreateParams.kt | 6 ++++++ .../api/models/CustomerUpdateByExternalIdParams.kt | 6 ++++++ .../com/withorb/api/models/CustomerUpdateParams.kt | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 438843fd3..9aa6a38b4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d6a851f21804170f796637f1911c3382f1c57f5ed6b9b77cd7d0c6f74c06e174.yml -openapi_spec_hash: 82df33badf54d0c7087a61145d379f58 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b1440d47f0b1b1b92f2e40f9ad5efd301d90f66e2e05c5a932902608935aa64.yml +openapi_spec_hash: 14f386604d0d87d9459352b8a7b84eff config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index ddbd8b498..465f59cbb 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -1843,6 +1843,8 @@ private constructor( val NETSUITE = of("netsuite") + val NETSUITE_AMPERSAND = of("netsuite_ampersand") + fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -1853,6 +1855,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -1870,6 +1873,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -1891,6 +1895,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -1909,6 +1914,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } @@ -2376,6 +2382,8 @@ private constructor( val NETSUITE = of("netsuite") + val NETSUITE_AMPERSAND = of("netsuite_ampersand") + fun of(value: String) = ProviderType(JsonField.of(value)) } @@ -2383,6 +2391,7 @@ private constructor( enum class Known { QUICKBOOKS, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -2398,6 +2407,7 @@ private constructor( enum class Value { QUICKBOOKS, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [ProviderType] was instantiated with an * unknown value. @@ -2416,6 +2426,7 @@ private constructor( when (this) { QUICKBOOKS -> Value.QUICKBOOKS NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -2432,6 +2443,7 @@ private constructor( when (this) { QUICKBOOKS -> Known.QUICKBOOKS NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown ProviderType: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index 23c921ce8..bcb6678b3 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -3441,6 +3441,8 @@ private constructor( val NETSUITE = of("netsuite") + val NETSUITE_AMPERSAND = of("netsuite_ampersand") + fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -3451,6 +3453,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -3468,6 +3471,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -3489,6 +3493,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -3507,6 +3512,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 079097c94..d177aad3d 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -3363,6 +3363,8 @@ private constructor( val NETSUITE = of("netsuite") + val NETSUITE_AMPERSAND = of("netsuite_ampersand") + fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -3373,6 +3375,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -3390,6 +3393,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -3411,6 +3415,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -3429,6 +3434,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index e97b351d9..2f36007e9 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -3360,6 +3360,8 @@ private constructor( val NETSUITE = of("netsuite") + val NETSUITE_AMPERSAND = of("netsuite_ampersand") + fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -3370,6 +3372,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -3387,6 +3390,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -3408,6 +3412,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -3426,6 +3431,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } From 67887bfd41f3744589a59299b8b4b69c136dfc1e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 17:05:02 +0000 Subject: [PATCH 30/52] chore(tests): update mock server to steady --- .stats.yml | 2 +- scripts/mock | 26 +++++++++++++------------- scripts/test | 16 ++++++++-------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9aa6a38b4..53731fc5f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b1440d47f0b1b1b92f2e40f9ad5efd301d90f66e2e05c5a932902608935aa64.yml openapi_spec_hash: 14f386604d0d87d9459352b8a7b84eff -config_hash: 3279841440b02d4e8303c961d6983492 +config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/scripts/mock b/scripts/mock index bcf3b392b..3d1d19c19 100755 --- a/scripts/mock +++ b/scripts/mock @@ -19,34 +19,34 @@ fi echo "==> Starting mock server with URL ${URL}" -# Run prism mock on the given spec +# Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stdy/cli@0.19.3 -- steady --version - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & - # Wait for server to come online (max 30s) + # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" attempts=0 - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do + if ! kill -0 $! 2>/dev/null; then + echo + cat .stdy.log + exit 1 + fi attempts=$((attempts + 1)) if [ "$attempts" -ge 300 ]; then echo - echo "Timed out waiting for Prism server to start" - cat .prism.log + echo "Timed out waiting for Steady server to start" + cat .stdy.log exit 1 fi echo -n "." sleep 0.1 done - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - echo else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" + npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 047bc1dbb..2061cfa81 100755 --- a/scripts/test +++ b/scripts/test @@ -9,8 +9,8 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 +function steady_is_running() { + curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1 } kill_server_on_port() { @@ -25,7 +25,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running ; then +if ! is_overriding_api_base_url && ! steady_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -36,19 +36,19 @@ fi if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" +elif ! steady_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" + echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}" echo fi From 5fceea66f7cc3148c01a0a33c81000cf1fbfd1a1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 20:55:51 +0000 Subject: [PATCH 31/52] chore(internal): tweak CI branches --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba47facd6..ec631044e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' From b77931f2d6025e820c84c9a01626321c73a65240 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:51:54 +0000 Subject: [PATCH 32/52] chore(internal): update retry delay tests --- .../com/withorb/api/core/http/RetryingHttpClientTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index 2ec15348b..3ef642cb3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -394,9 +394,9 @@ internal class RetryingHttpClientTest { assertThat(sleeper.durations).hasSize(3) // retries=1: 0.5s * [0.75, 1.0] assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) - // retries=2: 1.0s * [0.75, 1.0] + // retries=2: 1s * [0.75, 1.0] assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) - // retries=3: 2.0s * [0.75, 1.0] + // retries=3: 2s * [0.75, 1.0] assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) assertNoResponseLeaks() } @@ -421,9 +421,9 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(503) verify(7, postRequestedFor(urlPathEqualTo("/something"))) assertThat(sleeper.durations).hasSize(6) - // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + // retries=5: backoff hits the 8s cap * [0.75, 1.0] assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) - // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + // retries=6: still capped at 8s * [0.75, 1.0] assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) assertNoResponseLeaks() } From 562fcc3e28663dc802d801a6c359cbc5c04c681a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:26:01 +0000 Subject: [PATCH 33/52] fix(client): allow updating header/query affecting fields in `toBuilder()` --- .../com/withorb/api/core/ClientOptions.kt | 7 +++--- .../com/withorb/api/core/ClientOptionsTest.kt | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt index d069c2855..9b106eedc 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -404,13 +404,14 @@ private constructor( headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) + // We replace after all the default headers to allow end-users to overwrite them. + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) apiKey.let { if (!it.isEmpty()) { - headers.put("Authorization", "Bearer $it") + headers.replace("Authorization", "Bearer $it") } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient, diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt index 24e6362fd..1a788d837 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt @@ -16,6 +16,29 @@ internal class ClientOptionsTest { private val httpClient = mock() + @Test + fun putHeader_canOverwriteDefaultHeader() { + val clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .putHeader("User-Agent", "My User Agent") + .apiKey("My API Key") + .build() + + assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") + } + + @Test + fun toBuilder_apiKeyAuthCanBeUpdated() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + + clientOptions = clientOptions.toBuilder().apiKey("another My API Key").build() + + assertThat(clientOptions.headers.values("Authorization")) + .containsExactly("Bearer another My API Key") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = From 86ce6f3f76500235d4ebba8c96e2a4c84d4343db Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 06:16:53 +0000 Subject: [PATCH 34/52] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/withorb/api/models/Customer.kt | 67 +++- .../api/models/CustomerCreateParams.kt | 67 +++- .../CustomerUpdateByExternalIdParams.kt | 67 +++- .../api/models/CustomerUpdateParams.kt | 67 +++- .../withorb/api/models/InvoicePayParams.kt | 306 +++++++++++++++--- .../api/services/async/InvoiceServiceAsync.kt | 21 +- .../services/async/InvoiceServiceAsyncImpl.kt | 2 +- .../api/services/blocking/InvoiceService.kt | 19 +- .../services/blocking/InvoiceServiceImpl.kt | 2 +- .../api/models/CustomerCreateParamsTest.kt | 3 + .../models/CustomerListPageResponseTest.kt | 3 + .../com/withorb/api/models/CustomerTest.kt | 3 + .../CustomerUpdateByExternalIdParamsTest.kt | 3 + .../api/models/CustomerUpdateParamsTest.kt | 3 + .../api/models/InvoicePayParamsTest.kt | 24 +- .../api/models/MutatedSubscriptionTest.kt | 3 + .../SubscriptionChangeApplyResponseTest.kt | 9 + .../SubscriptionChangeCancelResponseTest.kt | 9 + .../SubscriptionChangeRetrieveResponseTest.kt | 9 + .../withorb/api/models/SubscriptionTest.kt | 3 + .../withorb/api/models/SubscriptionsTest.kt | 9 + .../withorb/api/services/ErrorHandlingTest.kt | 17 + .../withorb/api/services/ServiceParamsTest.kt | 1 + .../async/CustomerServiceAsyncTest.kt | 3 + .../services/async/InvoiceServiceAsyncTest.kt | 9 +- .../services/blocking/CustomerServiceTest.kt | 3 + .../services/blocking/InvoiceServiceTest.kt | 9 +- 28 files changed, 658 insertions(+), 87 deletions(-) diff --git a/.stats.yml b/.stats.yml index 53731fc5f..3fd9b3caa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b1440d47f0b1b1b92f2e40f9ad5efd301d90f66e2e05c5a932902608935aa64.yml -openapi_spec_hash: 14f386604d0d87d9459352b8a7b84eff +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ebac75191b7fecb0dc03df5b9eeb62d99811905552ddc2a2bd5a7a77dbfe00d3.yml +openapi_spec_hash: 1b96488643f8c4bc07ea184aa2505ca7 config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 465f59cbb..66b4bcb22 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -2697,6 +2697,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -2706,10 +2707,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -2720,6 +2729,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): String? = + defaultSharedPaymentToken.getNullable("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -2743,6 +2763,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -2782,11 +2812,13 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -2807,6 +2839,26 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -2881,6 +2933,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -2894,6 +2947,7 @@ private constructor( } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -2914,6 +2968,7 @@ private constructor( */ internal fun validity(): Int = (providerType.asKnown()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown() == null) 0 else 1) + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) /** The payment provider to configure. */ @@ -3049,18 +3104,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index bcb6678b3..aa67884a7 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -3028,6 +3028,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -3037,10 +3038,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -3051,6 +3060,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): String? = + defaultSharedPaymentToken.getNullable("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -3074,6 +3094,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -3113,11 +3143,13 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -3138,6 +3170,26 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -3212,6 +3264,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3225,6 +3278,7 @@ private constructor( } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3245,6 +3299,7 @@ private constructor( */ internal fun validity(): Int = (providerType.asKnown()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown() == null) 0 else 1) + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) /** The payment provider to configure. */ @@ -3380,18 +3435,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index d177aad3d..229c4316c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -2947,6 +2947,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -2956,10 +2957,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -2970,6 +2979,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): String? = + defaultSharedPaymentToken.getNullable("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -2993,6 +3013,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -3032,11 +3062,13 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -3057,6 +3089,26 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -3131,6 +3183,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3144,6 +3197,7 @@ private constructor( } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3164,6 +3218,7 @@ private constructor( */ internal fun validity(): Int = (providerType.asKnown()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown() == null) 0 else 1) + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) /** The payment provider to configure. */ @@ -3299,18 +3354,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 2f36007e9..9c499c03b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -2944,6 +2944,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -2953,10 +2954,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -2967,6 +2976,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): String? = + defaultSharedPaymentToken.getNullable("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -2990,6 +3010,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -3029,11 +3059,13 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -3054,6 +3086,26 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -3128,6 +3180,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3141,6 +3194,7 @@ private constructor( } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3161,6 +3215,7 @@ private constructor( */ internal fun validity(): Int = (providerType.asKnown()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown() == null) 0 else 1) + (excludedPaymentMethodTypes.asKnown()?.size ?: 0) /** The payment provider to configure. */ @@ -3296,18 +3351,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt index f5a43a3c0..edf9e7dad 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt @@ -2,29 +2,54 @@ package com.withorb.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +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.Params +import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections import java.util.Objects /** - * 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". + * This endpoint collects payment for an invoice. By default, it uses the customer's default payment + * method. Optionally, a shared payment token (SPT) can be provided to pay using agent-granted + * credentials instead. This action can only be taken on invoices with status "issued". */ class InvoicePayParams private constructor( private val invoiceId: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { fun invoiceId(): String? = invoiceId - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * The ID of a shared payment token granted by an agent to use for this payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun sharedPaymentTokenId(): String = body.sharedPaymentTokenId() + + /** + * Returns the raw JSON value of [sharedPaymentTokenId]. + * + * Unlike [sharedPaymentTokenId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _sharedPaymentTokenId(): JsonField = body._sharedPaymentTokenId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -36,9 +61,14 @@ private constructor( companion object { - fun none(): InvoicePayParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [InvoicePayParams]. */ + /** + * Returns a mutable builder for constructing an instance of [InvoicePayParams]. + * + * The following fields are required: + * ```kotlin + * .sharedPaymentTokenId() + * ``` + */ fun builder() = Builder() } @@ -46,19 +76,63 @@ private constructor( class Builder internal constructor() { private var invoiceId: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() internal fun from(invoicePayParams: InvoicePayParams) = apply { invoiceId = invoicePayParams.invoiceId + body = invoicePayParams.body.toBuilder() additionalHeaders = invoicePayParams.additionalHeaders.toBuilder() additionalQueryParams = invoicePayParams.additionalQueryParams.toBuilder() - additionalBodyProperties = invoicePayParams.additionalBodyProperties.toMutableMap() } fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [sharedPaymentTokenId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The ID of a shared payment token granted by an agent to use for this payment. */ + fun sharedPaymentTokenId(sharedPaymentTokenId: String) = apply { + body.sharedPaymentTokenId(sharedPaymentTokenId) + } + + /** + * Sets [Builder.sharedPaymentTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPaymentTokenId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPaymentTokenId(sharedPaymentTokenId: JsonField) = apply { + body.sharedPaymentTokenId(sharedPaymentTokenId) + } + + 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) @@ -157,43 +231,28 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - /** * Returns an immutable instance of [InvoicePayParams]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .sharedPaymentTokenId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): InvoicePayParams = InvoicePayParams( invoiceId, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - fun _body(): Map? = additionalBodyProperties.ifEmpty { null } + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { @@ -205,6 +264,175 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sharedPaymentTokenId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("shared_payment_token_id") + @ExcludeMissing + sharedPaymentTokenId: JsonField = JsonMissing.of() + ) : this(sharedPaymentTokenId, mutableMapOf()) + + /** + * The ID of a shared payment token granted by an agent to use for this payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sharedPaymentTokenId(): String = + sharedPaymentTokenId.getRequired("shared_payment_token_id") + + /** + * Returns the raw JSON value of [sharedPaymentTokenId]. + * + * Unlike [sharedPaymentTokenId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("shared_payment_token_id") + @ExcludeMissing + fun _sharedPaymentTokenId(): JsonField = sharedPaymentTokenId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```kotlin + * .sharedPaymentTokenId() + * ``` + */ + fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var sharedPaymentTokenId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(body: Body) = apply { + sharedPaymentTokenId = body.sharedPaymentTokenId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The ID of a shared payment token granted by an agent to use for this payment. */ + fun sharedPaymentTokenId(sharedPaymentTokenId: String) = + sharedPaymentTokenId(JsonField.of(sharedPaymentTokenId)) + + /** + * Sets [Builder.sharedPaymentTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPaymentTokenId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sharedPaymentTokenId(sharedPaymentTokenId: JsonField) = apply { + this.sharedPaymentTokenId = sharedPaymentTokenId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```kotlin + * .sharedPaymentTokenId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("sharedPaymentTokenId", sharedPaymentTokenId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + sharedPaymentTokenId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + internal fun validity(): Int = (if (sharedPaymentTokenId.asKnown() == null) 0 else 1) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + sharedPaymentTokenId == other.sharedPaymentTokenId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sharedPaymentTokenId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{sharedPaymentTokenId=$sharedPaymentTokenId, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -212,14 +440,14 @@ private constructor( return other is InvoicePayParams && invoiceId == other.invoiceId && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(invoiceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "InvoicePayParams{invoiceId=$invoiceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "InvoicePayParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index c667be2ab..f1245ace5 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -242,12 +242,14 @@ interface InvoiceServiceAsync { ): Invoice /** - * 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". + * This endpoint collects payment for an invoice. By default, it uses the customer's default + * payment method. Optionally, a shared payment token (SPT) can be provided to pay using + * agent-granted credentials instead. This action can only be taken on invoices with status + * "issued". */ suspend fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), ): Invoice = pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) @@ -257,10 +259,6 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice - /** @see pay */ - suspend fun pay(invoiceId: String, requestOptions: RequestOptions): Invoice = - pay(invoiceId, InvoicePayParams.none(), requestOptions) - /** * This endpoint allows an invoice's status to be set to the `void` status. This can only be * done to invoices that are in the `issued` status. @@ -506,7 +504,7 @@ interface InvoiceServiceAsync { @MustBeClosed suspend fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) @@ -518,13 +516,6 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see pay */ - @MustBeClosed - suspend fun pay( - invoiceId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = pay(invoiceId, InvoicePayParams.none(), requestOptions) - /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the * same as [InvoiceServiceAsync.void]. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt index e854a49b8..6799a3ec4 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt @@ -464,7 +464,7 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) .addPathSegments("invoices", params._pathParam(0), "pay") - .apply { params._body()?.let { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index 9f657098e..05c95e739 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -242,12 +242,14 @@ interface InvoiceService { ): Invoice /** - * 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". + * This endpoint collects payment for an invoice. By default, it uses the customer's default + * payment method. Optionally, a shared payment token (SPT) can be provided to pay using + * agent-granted credentials instead. This action can only be taken on invoices with status + * "issued". */ fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), ): Invoice = pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) @@ -257,10 +259,6 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice - /** @see pay */ - fun pay(invoiceId: String, requestOptions: RequestOptions): Invoice = - pay(invoiceId, InvoicePayParams.none(), requestOptions) - /** * This endpoint allows an invoice's status to be set to the `void` status. This can only be * done to invoices that are in the `issued` status. @@ -494,7 +492,7 @@ interface InvoiceService { @MustBeClosed fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) @@ -506,11 +504,6 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see pay */ - @MustBeClosed - fun pay(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = - pay(invoiceId, InvoicePayParams.none(), requestOptions) - /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the * same as [InvoiceService.void]. diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt index 8622376bd..7e47cd334 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt @@ -446,7 +446,7 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) .addPathSegments("invoices", params._pathParam(0), "pay") - .apply { params._body()?.let { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt index cae6f5600..2c3150c09 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt @@ -60,6 +60,7 @@ internal class CustomerCreateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -150,6 +151,7 @@ internal class CustomerCreateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -242,6 +244,7 @@ internal class CustomerCreateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt index 94a0f1744..c966844ef 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt @@ -107,6 +107,7 @@ internal class CustomerListPageResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -213,6 +214,7 @@ internal class CustomerListPageResponseTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -324,6 +326,7 @@ internal class CustomerListPageResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index 2ec513af7..e59a8e55f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -103,6 +103,7 @@ internal class CustomerTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -206,6 +207,7 @@ internal class CustomerTest { .providerType( Customer.PaymentConfiguration.PaymentProvider.ProviderType.STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -308,6 +310,7 @@ internal class CustomerTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt index 8ad7c6acc..936819a4b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParamsTest.kt @@ -63,6 +63,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -164,6 +165,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -257,6 +259,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt index 823e476a7..be7ac25f0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerUpdateParamsTest.kt @@ -61,6 +61,7 @@ internal class CustomerUpdateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -160,6 +161,7 @@ internal class CustomerUpdateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -251,6 +253,7 @@ internal class CustomerUpdateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt index 961deaa25..65bfd6f01 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt @@ -9,15 +9,35 @@ internal class InvoicePayParamsTest { @Test fun create() { - InvoicePayParams.builder().invoiceId("invoice_id").build() + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() } @Test fun pathParams() { - val params = InvoicePayParams.builder().invoiceId("invoice_id").build() + val params = + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() assertThat(params._pathParam(0)).isEqualTo("invoice_id") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } + + @Test + fun body() { + val params = + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() + + val body = params._body() + + assertThat(body.sharedPaymentTokenId()).isEqualTo("shared_payment_token_id") + } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 76dc25aad..909552142 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -151,6 +151,7 @@ internal class MutatedSubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1913,6 +1914,7 @@ internal class MutatedSubscriptionTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -3615,6 +3617,7 @@ internal class MutatedSubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 0a067b43c..5c465227f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -168,6 +168,9 @@ internal class SubscriptionChangeApplyResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -2194,6 +2197,9 @@ internal class SubscriptionChangeApplyResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -4110,6 +4116,9 @@ internal class SubscriptionChangeApplyResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 6fb3a8301..9914686c5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -168,6 +168,9 @@ internal class SubscriptionChangeCancelResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -2194,6 +2197,9 @@ internal class SubscriptionChangeCancelResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -4110,6 +4116,9 @@ internal class SubscriptionChangeCancelResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 1740dc31a..53f449ab6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -168,6 +168,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -2194,6 +2197,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -4110,6 +4116,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 5d5c6056a..7ca1a3807 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -151,6 +151,7 @@ internal class SubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -841,6 +842,7 @@ internal class SubscriptionTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1534,6 +1536,7 @@ internal class SubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index b42ac5aa4..00056652a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -164,6 +164,9 @@ internal class SubscriptionsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -927,6 +930,9 @@ internal class SubscriptionsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -1664,6 +1670,9 @@ internal class SubscriptionsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt index 0de61a15a..9f1e458af 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ErrorHandlingTest.kt @@ -130,6 +130,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -240,6 +241,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -350,6 +352,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -460,6 +463,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -570,6 +574,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -680,6 +685,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -790,6 +796,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -900,6 +907,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1010,6 +1018,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1120,6 +1129,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1230,6 +1240,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1340,6 +1351,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1450,6 +1462,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1560,6 +1573,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1670,6 +1684,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1780,6 +1795,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1888,6 +1904,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt index 447c39875..b2f843eb0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/ServiceParamsTest.kt @@ -98,6 +98,7 @@ internal class ServiceParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt index f7d254448..1d2f09a3b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/CustomerServiceAsyncTest.kt @@ -82,6 +82,7 @@ internal class CustomerServiceAsyncTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -186,6 +187,7 @@ internal class CustomerServiceAsyncTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -372,6 +374,7 @@ internal class CustomerServiceAsyncTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 419d1059e..2e68d715a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount import com.withorb.api.models.UnitConfig @@ -258,7 +259,13 @@ internal class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoice = invoiceServiceAsync.pay("invoice_id") + val invoice = + invoiceServiceAsync.pay( + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() + ) invoice.validate() } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt index 30037704e..c4be2ce38 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/CustomerServiceTest.kt @@ -82,6 +82,7 @@ internal class CustomerServiceTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -186,6 +187,7 @@ internal class CustomerServiceTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -370,6 +372,7 @@ internal class CustomerServiceTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 939d58e04..5350e229a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -11,6 +11,7 @@ import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount import com.withorb.api.models.UnitConfig @@ -258,7 +259,13 @@ internal class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = invoiceService.pay("invoice_id") + val invoice = + invoiceService.pay( + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() + ) invoice.validate() } From 24a716abbe941baed09fedde8e5ef860e65e01ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:25:01 +0000 Subject: [PATCH 35/52] chore(internal): bump ktfmt --- buildSrc/src/main/kotlin/orb.kotlin.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts index 78bb0bbc3..9f10a4f06 100644 --- a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts @@ -40,7 +40,7 @@ tasks.withType().configureEach { val ktfmt by configurations.creating dependencies { - ktfmt("com.facebook:ktfmt:0.56") + ktfmt("com.facebook:ktfmt:0.61") } fun registerKtfmt( From 849d3de8b4ea87f9d0468a7375f0fdcb643e5cbc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:52:17 +0000 Subject: [PATCH 36/52] chore(tests): bump steady to v0.19.4 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 3d1d19c19..e2ca85a09 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.3 -- steady --version + npm exec --package=@stdy/cli@0.19.4 -- steady --version - npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 2061cfa81..c1b84719d 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.4 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From a10b51221a51c8316be0ea100d22aa621e1672ad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 21:43:17 +0000 Subject: [PATCH 37/52] chore(tests): bump steady to v0.19.5 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index e2ca85a09..4f7dfd12b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.4 -- steady --version + npm exec --package=@stdy/cli@0.19.5 -- steady --version - npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.4 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index c1b84719d..d2b863fbb 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.4 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.5 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From fa67c1226f96926bce3720704e5fff5a29871679 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 14:10:01 +0000 Subject: [PATCH 38/52] chore(internal): update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b1346e6d1..90b85e944 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .gradle .idea .kotlin From db03fe4c53ad646d5de1f7bd7a58bb1d9554c768 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 18:05:00 +0000 Subject: [PATCH 39/52] chore(tests): bump steady to v0.19.6 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 4f7dfd12b..dba305898 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.5 -- steady --version + npm exec --package=@stdy/cli@0.19.6 -- steady --version - npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index d2b863fbb..185969677 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.5 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.6 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From 847e8399ce5cd8c10fcf1abeeaba3184a0695b9f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:18:20 +0000 Subject: [PATCH 40/52] chore(ci): skip lint on metadata-only changes Note that we still want to run tests, as these depend on the metadata. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec631044e..18e4c314e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -43,7 +43,7 @@ jobs: timeout-minutes: 15 name: build runs-on: ${{ github.repository == 'stainless-sdks/orb-kotlin' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 From 7f90cdf8a4b13e32a35eb69e48643dc3bbf7388e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:45:34 +0000 Subject: [PATCH 41/52] chore(tests): bump steady to v0.19.7 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index dba305898..9ecceca0a 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.6 -- steady --version + npm exec --package=@stdy/cli@0.19.7 -- steady --version - npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.6 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 185969677..c50adf50b 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.6 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" echo exit 1 From a0f53b00b27077118e8da9afc249843109aad174 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 21:15:21 +0000 Subject: [PATCH 42/52] feat(api): api update --- .stats.yml | 4 ++-- .../withorb/api/models/DecrementLedgerEntry.kt | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3fd9b3caa..cce75ba91 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ebac75191b7fecb0dc03df5b9eeb62d99811905552ddc2a2bd5a7a77dbfe00d3.yml -openapi_spec_hash: 1b96488643f8c4bc07ea184aa2505ca7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b1ac6575304b8d616a2d758bfaa630d9b909f22b6bf0259cf01ee87e2db1229f.yml +openapi_spec_hash: fb87fae72aa232e036f2fc029919412c config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt index 6d0b26325..d51fd3330 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt @@ -179,10 +179,13 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") /** + * This field is deprecated and will always be null. Decrements are not associated with + * individual events. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun eventId(): String? = eventId.getNullable("event_id") + @Deprecated("deprecated") fun eventId(): String? = eventId.getNullable("event_id") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -307,7 +310,10 @@ private constructor( * * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId + @Deprecated("deprecated") + @JsonProperty("event_id") + @ExcludeMissing + fun _eventId(): JsonField = eventId /** * Returns the raw JSON value of [invoiceId]. @@ -558,6 +564,11 @@ private constructor( this.startingBalance = startingBalance } + /** + * This field is deprecated and will always be null. Decrements are not associated with + * individual events. + */ + @Deprecated("deprecated") fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) /** @@ -566,6 +577,7 @@ private constructor( * You should usually call [Builder.eventId] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ + @Deprecated("deprecated") fun eventId(eventId: JsonField) = apply { this.eventId = eventId } fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) From 19c71b8c6496a0b7df9e9233176e3ed6f7b77935 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 22:15:18 +0000 Subject: [PATCH 43/52] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index cce75ba91..c2abdb90f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-b1ac6575304b8d616a2d758bfaa630d9b909f22b6bf0259cf01ee87e2db1229f.yml -openapi_spec_hash: fb87fae72aa232e036f2fc029919412c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-17c43dab26af75e1b9f7e61ac8da1219cea65c7d0666d98686b71a60183e458d.yml +openapi_spec_hash: bbbd86881508bb69904eacdbce1e52b6 config_hash: c01c1191b1cd696c7ca855ff6d28a8df From f8ee81005fb308a952e6fd946680c8e7d3f04190 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:27:32 +0000 Subject: [PATCH 44/52] chore(internal): update multipart form array serialization --- scripts/mock | 4 ++-- scripts/test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mock b/scripts/mock index 9ecceca0a..4931f304c 100755 --- a/scripts/mock +++ b/scripts/mock @@ -24,7 +24,7 @@ if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout npm exec --package=@stdy/cli@0.19.7 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index c50adf50b..70bb0c3b5 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=brackets --validator-query-array-format=brackets --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 60af3d0eafd87bccc861e9c586f384869042f50d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:30:12 +0000 Subject: [PATCH 45/52] chore(tests): bump steady to v0.20.1 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 4931f304c..8b82c3e59 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.19.7 -- steady --version + npm exec --package=@stdy/cli@0.20.1 -- steady --version - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.7 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 70bb0c3b5..29bc2a9e6 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.7 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From e14d7367cdc95d1f70b2efe1cf6adf6c8e5dc9b0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:15:08 +0000 Subject: [PATCH 46/52] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c2abdb90f..d7991c07b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-17c43dab26af75e1b9f7e61ac8da1219cea65c7d0666d98686b71a60183e458d.yml -openapi_spec_hash: bbbd86881508bb69904eacdbce1e52b6 +openapi_spec_hash: 7d7f4d41ccb2023153327ca685dcf942 config_hash: c01c1191b1cd696c7ca855ff6d28a8df From 196c645c4bf289fb6ecfa7165e8b417679c52f0e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:19:48 +0000 Subject: [PATCH 47/52] chore(tests): bump steady to v0.20.2 --- scripts/mock | 6 +++--- scripts/test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mock b/scripts/mock index 8b82c3e59..886f2ffc1 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stdy/cli@0.20.1 -- steady --version + npm exec --package=@stdy/cli@0.20.2 -- steady --version - npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.20.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 29bc2a9e6..6e4e0a891 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 From 2f25f860175c24c187e7f8ffd2d283f0017b8722 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:15:05 +0000 Subject: [PATCH 48/52] feat(api): api update --- .stats.yml | 4 ++-- .../main/kotlin/com/withorb/api/models/CouponListParams.kt | 2 +- .../com/withorb/api/models/EventBackfillCreateParams.kt | 3 ++- .../com/withorb/api/models/EventBackfillListParams.kt | 3 +-- .../com/withorb/api/models/SubscriptionFetchCostsParams.kt | 6 +++--- .../com/withorb/api/services/async/CouponServiceAsync.kt | 3 +-- .../withorb/api/services/async/SubscriptionServiceAsync.kt | 6 +++--- .../api/services/async/events/BackfillServiceAsync.kt | 6 +++--- .../com/withorb/api/services/blocking/CouponService.kt | 3 +-- .../withorb/api/services/blocking/SubscriptionService.kt | 6 +++--- .../withorb/api/services/blocking/events/BackfillService.kt | 6 +++--- 11 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.stats.yml b/.stats.yml index d7991c07b..e1694adf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-17c43dab26af75e1b9f7e61ac8da1219cea65c7d0666d98686b71a60183e458d.yml -openapi_spec_hash: 7d7f4d41ccb2023153327ca685dcf942 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1ca41c4b1d872cf2a198c8cf5edeeeddac012259a7cf211b102bf137c05b8240.yml +openapi_spec_hash: 955066d4865fc42440cd81e40f5f79cd config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt index 2af9ee208..a41a4b24f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt @@ -12,7 +12,7 @@ import java.util.Objects * * 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. + * exist. */ class CouponListParams private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index aa0e14457..3c55c4cf2 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -23,7 +23,8 @@ import java.util.Objects * 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`). + * 2. [Ingest](/api-reference/event/ingest-events) 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 diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt index ed7ec4453..1ee2ad220 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt @@ -12,8 +12,7 @@ import java.util.Objects * * The list of backfills is ordered starting from the most recently created backfill. The response * also includes [`pagination_metadata`](/api-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). + * the next page of results if they exist. */ class EventBackfillListParams private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt index 9c151623c..3bdc2983b 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt @@ -20,9 +20,9 @@ import java.util.Objects * 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). + * [fetching a customer's costs](/api-reference/customer/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 private constructor( diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt index c1d0d2a04..1822d8514 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt @@ -56,8 +56,7 @@ interface CouponServiceAsync { * * 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. + * if they exist. */ suspend fun list( params: CouponListParams = CouponListParams.none(), diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt index 70f4ff403..fa43af872 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt @@ -425,9 +425,9 @@ interface SubscriptionServiceAsync { * 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). + * [fetching a customer's costs](/api-reference/customer/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). */ suspend fun fetchCosts( subscriptionId: String, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt index 733124cb5..af2b8b81c 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt @@ -40,7 +40,8 @@ interface BackfillServiceAsync { * 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`). + * 2. [Ingest](/api-reference/event/ingest-events) 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 @@ -79,8 +80,7 @@ interface BackfillServiceAsync { * * The list of backfills is ordered starting from the most recently created backfill. The * response also includes [`pagination_metadata`](/api-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). + * caller retrieve the next page of results if they exist. */ suspend fun list( params: EventBackfillListParams = EventBackfillListParams.none(), diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt index 9fee04394..b10634b5f 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt @@ -56,8 +56,7 @@ interface CouponService { * * 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. + * if they exist. */ fun list( params: CouponListParams = CouponListParams.none(), diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt index 85fe68e11..9076f6f14 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt @@ -425,9 +425,9 @@ interface SubscriptionService { * 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). + * [fetching a customer's costs](/api-reference/customer/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). */ fun fetchCosts( subscriptionId: String, diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt index 5a4e55cf0..a3ee67368 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt @@ -40,7 +40,8 @@ interface BackfillService { * 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`). + * 2. [Ingest](/api-reference/event/ingest-events) 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 @@ -79,8 +80,7 @@ interface BackfillService { * * The list of backfills is ordered starting from the most recently created backfill. The * response also includes [`pagination_metadata`](/api-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). + * caller retrieve the next page of results if they exist. */ fun list( params: EventBackfillListParams = EventBackfillListParams.none(), From f1ab4b89f00819f7dc49af9c2163d5372a416327 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 18:09:31 +0000 Subject: [PATCH 49/52] docs: improve examples --- .../models/PlanMigrationCancelResponseTest.kt | 9 ++-- .../PlanMigrationListPageResponseTest.kt | 11 +++-- .../models/PlanMigrationListResponseTest.kt | 9 ++-- .../PlanMigrationRetrieveResponseTest.kt | 9 ++-- .../SubscriptionPriceIntervalsParamsTest.kt | 48 +++++++++---------- .../async/SubscriptionServiceAsyncTest.kt | 17 +++---- .../blocking/SubscriptionServiceTest.kt | 17 +++---- 7 files changed, 63 insertions(+), 57 deletions(-) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt index 8c0089470..9a2a297f0 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +14,7 @@ internal class PlanMigrationCancelResponseTest { val planMigrationCancelResponse = PlanMigrationCancelResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationCancelResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationCancelResponse.Status.NOT_STARTED) .build() @@ -23,7 +22,9 @@ internal class PlanMigrationCancelResponseTest { assertThat(planMigrationCancelResponse.id()).isEqualTo("id") assertThat(planMigrationCancelResponse.effectiveTime()) .isEqualTo( - PlanMigrationCancelResponse.EffectiveTime.ofLocalDate(LocalDate.parse("2019-12-27")) + PlanMigrationCancelResponse.EffectiveTime.ofUnionMember2( + PlanMigrationCancelResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) ) assertThat(planMigrationCancelResponse.planId()).isEqualTo("plan_id") assertThat(planMigrationCancelResponse.status()) @@ -36,7 +37,7 @@ internal class PlanMigrationCancelResponseTest { val planMigrationCancelResponse = PlanMigrationCancelResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationCancelResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationCancelResponse.Status.NOT_STARTED) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt index 27e2f6f52..e69638f15 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,7 +16,9 @@ internal class PlanMigrationListPageResponseTest { .addData( PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime( + PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() @@ -31,7 +32,7 @@ internal class PlanMigrationListPageResponseTest { .containsExactly( PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() @@ -48,7 +49,9 @@ internal class PlanMigrationListPageResponseTest { .addData( PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime( + PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt index 897f00b3d..0500ea6d5 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +14,7 @@ internal class PlanMigrationListResponseTest { val planMigrationListResponse = PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() @@ -23,7 +22,9 @@ internal class PlanMigrationListResponseTest { assertThat(planMigrationListResponse.id()).isEqualTo("id") assertThat(planMigrationListResponse.effectiveTime()) .isEqualTo( - PlanMigrationListResponse.EffectiveTime.ofLocalDate(LocalDate.parse("2019-12-27")) + PlanMigrationListResponse.EffectiveTime.ofUnionMember2( + PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) ) assertThat(planMigrationListResponse.planId()).isEqualTo("plan_id") assertThat(planMigrationListResponse.status()) @@ -36,7 +37,7 @@ internal class PlanMigrationListResponseTest { val planMigrationListResponse = PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt index c6fb67b9b..15fd0c69a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +14,7 @@ internal class PlanMigrationRetrieveResponseTest { val planMigrationRetrieveResponse = PlanMigrationRetrieveResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationRetrieveResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationRetrieveResponse.Status.NOT_STARTED) .build() @@ -23,8 +22,8 @@ internal class PlanMigrationRetrieveResponseTest { assertThat(planMigrationRetrieveResponse.id()).isEqualTo("id") assertThat(planMigrationRetrieveResponse.effectiveTime()) .isEqualTo( - PlanMigrationRetrieveResponse.EffectiveTime.ofLocalDate( - LocalDate.parse("2019-12-27") + PlanMigrationRetrieveResponse.EffectiveTime.ofUnionMember2( + PlanMigrationRetrieveResponse.EffectiveTime.UnionMember2.END_OF_TERM ) ) assertThat(planMigrationRetrieveResponse.planId()).isEqualTo("plan_id") @@ -38,7 +37,7 @@ internal class PlanMigrationRetrieveResponseTest { val planMigrationRetrieveResponse = PlanMigrationRetrieveResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationRetrieveResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationRetrieveResponse.Status.NOT_STARTED) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 3952403d3..cf3146f80 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -15,7 +15,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -42,7 +42,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -115,7 +115,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -140,7 +140,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -150,7 +150,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition.builder() @@ -163,15 +163,15 @@ internal class SubscriptionPriceIntervalsParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() @@ -194,7 +194,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -221,7 +221,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -297,7 +297,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -322,7 +322,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -332,7 +332,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition @@ -346,15 +346,15 @@ internal class SubscriptionPriceIntervalsParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() @@ -364,7 +364,7 @@ internal class SubscriptionPriceIntervalsParamsTest { assertThat(body.add()) .containsExactly( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -391,7 +391,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -465,7 +465,7 @@ internal class SubscriptionPriceIntervalsParamsTest { assertThat(body.addAdjustments()) .containsExactly( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -490,7 +490,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) assertThat(body.allowInvoiceCreditOrVoid()).isEqualTo(true) @@ -501,7 +501,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition.builder() @@ -514,7 +514,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) @@ -522,8 +522,8 @@ internal class SubscriptionPriceIntervalsParamsTest { .containsExactly( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index f0de5abfb..39ac0a316 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.BillingCycleAnchorConfiguration +import com.withorb.api.models.BillingCycleRelativeDate import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.CustomExpiration import com.withorb.api.models.DiscountOverride @@ -534,7 +535,7 @@ internal class SubscriptionServiceAsyncTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -561,7 +562,7 @@ internal class SubscriptionServiceAsyncTest { ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -642,7 +643,7 @@ internal class SubscriptionServiceAsyncTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -669,7 +670,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -679,7 +680,7 @@ internal class SubscriptionServiceAsyncTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition @@ -694,15 +695,15 @@ internal class SubscriptionServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 96de618eb..8146fd2ae 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -6,6 +6,7 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.BillingCycleAnchorConfiguration +import com.withorb.api.models.BillingCycleRelativeDate import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.CustomExpiration import com.withorb.api.models.DiscountOverride @@ -534,7 +535,7 @@ internal class SubscriptionServiceTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -561,7 +562,7 @@ internal class SubscriptionServiceTest { ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -642,7 +643,7 @@ internal class SubscriptionServiceTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -669,7 +670,7 @@ internal class SubscriptionServiceTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -679,7 +680,7 @@ internal class SubscriptionServiceTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition @@ -694,15 +695,15 @@ internal class SubscriptionServiceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() From ffa5b92f2d89afa95c12a8d4fd6c608c983b3eac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 00:15:17 +0000 Subject: [PATCH 50/52] feat(api): api update --- .stats.yml | 4 +- .../models/CreditBlockListInvoicesParams.kt | 15 +- .../kotlin/com/withorb/api/models/Price.kt | 1426 ++++++++++++++++- .../services/async/CreditBlockServiceAsync.kt | 15 +- .../services/blocking/CreditBlockService.kt | 15 +- .../withorb/api/models/AggregatedCostTest.kt | 3 + .../ChangedSubscriptionResourcesTest.kt | 6 + ...ustomerCostListByExternalIdResponseTest.kt | 3 + .../models/CustomerCostListResponseTest.kt | 3 + ...dgerCreateEntryByExternalIdResponseTest.kt | 2 + ...omerCreditLedgerCreateEntryResponseTest.kt | 2 + ...tLedgerListByExternalIdPageResponseTest.kt | 3 + ...reditLedgerListByExternalIdResponseTest.kt | 2 + ...ustomerCreditLedgerListPageResponseTest.kt | 3 + .../CustomerCreditLedgerListResponseTest.kt | 2 + .../api/models/IncrementLedgerEntryTest.kt | 3 + .../InvoiceFetchUpcomingResponseTest.kt | 3 + .../InvoiceLineItemCreateResponseTest.kt | 3 + .../api/models/InvoiceListPageResponseTest.kt | 3 + .../com/withorb/api/models/InvoiceTest.kt | 3 + .../api/models/MutatedSubscriptionTest.kt | 12 + .../withorb/api/models/PerPriceCostTest.kt | 3 + .../api/models/PlanListPageResponseTest.kt | 3 + .../kotlin/com/withorb/api/models/PlanTest.kt | 3 + .../com/withorb/api/models/PlanVersionTest.kt | 3 + .../withorb/api/models/PriceIntervalTest.kt | 3 + .../api/models/PriceListPageResponseTest.kt | 3 + .../com/withorb/api/models/PriceTest.kt | 62 + .../SubscriptionChangeApplyResponseTest.kt | 12 + .../SubscriptionChangeCancelResponseTest.kt | 12 + .../SubscriptionChangeRetrieveResponseTest.kt | 12 + .../SubscriptionFetchCostsResponseTest.kt | 3 + .../withorb/api/models/SubscriptionTest.kt | 6 + .../withorb/api/models/SubscriptionsTest.kt | 6 + 34 files changed, 1611 insertions(+), 51 deletions(-) diff --git a/.stats.yml b/.stats.yml index e1694adf6..87a29a7d9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1ca41c4b1d872cf2a198c8cf5edeeeddac012259a7cf211b102bf137c05b8240.yml -openapi_spec_hash: 955066d4865fc42440cd81e40f5f79cd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2b77f13a159cf689a3bba6ac5ff03b6c0df62b772e2da04aff52be86710ca4d4.yml +openapi_spec_hash: 28a3f685403d98ddd68b427d92ed28fb config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt index ce7bf6d35..2f8564a93 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt @@ -10,13 +10,16 @@ import java.util.Objects /** * This endpoint returns the credit block and its associated purchasing invoices. * - * If a credit block was purchased (as opposed to being manually added or allocated from a - * subscription), this endpoint returns the invoices that were created to charge the customer for - * the credit block. For credit blocks with payment schedules spanning multiple periods (e.g., - * monthly payments over 12 months), multiple invoices will be returned. + * If a credit block was purchased (as opposed to being manually added), this endpoint returns the + * invoices that were created to charge the customer for the credit block. For credit blocks with + * payment schedules spanning multiple periods (e.g., monthly payments over 12 months), multiple + * invoices will be returned. * - * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices - * list is returned. + * For credit blocks created by subscription allocation prices, this endpoint returns the + * subscription invoice containing the allocation line item that created the block. + * + * If the credit block was not purchased (e.g., manual increment), an empty invoices list is + * returned. * * **Note: This endpoint is currently experimental and its interface may change in future releases. * Please contact support before building production integrations against this endpoint.** diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt index 85c4861e1..10f67d362 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1150,6 +1150,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -1208,6 +1209,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -1259,6 +1263,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -1364,6 +1369,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1610,6 +1621,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -1775,6 +1796,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -1809,6 +1831,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -1842,6 +1865,7 @@ private constructor( discount = unitPrice.discount externalPriceId = unitPrice.externalPriceId fixedPriceQuantity = unitPrice.fixedPriceQuantity + invoiceGroupingKey = unitPrice.invoiceGroupingKey invoicingCycleConfiguration = unitPrice.invoicingCycleConfiguration item = unitPrice.item maximum = unitPrice.maximum @@ -2192,6 +2216,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -2459,6 +2497,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -2493,6 +2532,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -2533,6 +2573,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -2584,6 +2625,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -3937,6 +3979,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -3971,6 +4014,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -3993,7 +4037,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Tiered @@ -4013,6 +4057,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -4071,6 +4116,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -4122,6 +4170,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -4227,6 +4276,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4473,6 +4528,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -4639,6 +4704,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -4673,6 +4739,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -4706,6 +4773,7 @@ private constructor( discount = tiered.discount externalPriceId = tiered.externalPriceId fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey invoicingCycleConfiguration = tiered.invoicingCycleConfiguration item = tiered.item maximum = tiered.maximum @@ -5056,6 +5124,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -5323,6 +5405,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -5357,6 +5440,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -5397,6 +5481,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -5448,6 +5533,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -6801,6 +6887,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -6835,6 +6922,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -6857,7 +6945,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Bulk @@ -6878,6 +6966,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -6938,6 +7027,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -6987,6 +7079,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -7099,6 +7192,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -7346,6 +7445,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -7503,6 +7612,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -7537,6 +7647,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -7570,6 +7681,7 @@ private constructor( discount = bulk.discount externalPriceId = bulk.externalPriceId fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey invoicingCycleConfiguration = bulk.invoicingCycleConfiguration item = bulk.item maximum = bulk.maximum @@ -7933,6 +8045,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -8187,6 +8313,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -8221,6 +8348,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -8261,6 +8389,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -8312,6 +8441,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -9665,6 +9795,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -9699,6 +9830,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -9720,7 +9852,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithFilters @@ -9741,6 +9873,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -9801,6 +9934,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -9850,6 +9986,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -9963,6 +10100,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -10211,6 +10354,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -10368,6 +10521,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -10402,6 +10556,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -10436,6 +10591,7 @@ private constructor( discount = bulkWithFilters.discount externalPriceId = bulkWithFilters.externalPriceId fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration item = bulkWithFilters.item maximum = bulkWithFilters.maximum @@ -10801,6 +10957,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -11055,6 +11225,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -11089,6 +11260,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -11129,6 +11301,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -11180,6 +11353,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -13205,6 +13379,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -13239,6 +13414,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -13260,7 +13436,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Package @@ -13280,6 +13456,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -13338,6 +13515,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -13389,6 +13569,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -13494,6 +13675,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -13740,6 +13927,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -13906,6 +14103,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -13940,6 +14138,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -13973,6 +14172,7 @@ private constructor( discount = package_.discount externalPriceId = package_.externalPriceId fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey invoicingCycleConfiguration = package_.invoicingCycleConfiguration item = package_.item maximum = package_.maximum @@ -14323,6 +14523,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -14591,6 +14805,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -14625,6 +14840,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -14665,6 +14881,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -14716,6 +14933,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -16069,6 +16287,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -16103,6 +16322,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -16125,7 +16345,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Matrix @@ -16145,6 +16365,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val matrixConfig: JsonField, @@ -16203,6 +16424,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -16254,6 +16478,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixConfig, @@ -16359,6 +16584,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -16605,6 +16836,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -16771,6 +17012,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixConfig() @@ -16805,6 +17047,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var matrixConfig: JsonField? = null @@ -16838,6 +17081,7 @@ private constructor( discount = matrix.discount externalPriceId = matrix.externalPriceId fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey invoicingCycleConfiguration = matrix.invoicingCycleConfiguration item = matrix.item matrixConfig = matrix.matrixConfig @@ -17188,6 +17432,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -17455,6 +17713,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixConfig() @@ -17489,6 +17748,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("matrixConfig", matrixConfig), @@ -17529,6 +17789,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() matrixConfig().validate() @@ -17580,6 +17841,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (matrixConfig.asKnown()?.validity() ?: 0) + @@ -18933,6 +19195,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixConfig == other.matrixConfig && @@ -18967,6 +19230,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixConfig, @@ -18989,7 +19253,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ThresholdTotalAmount @@ -19009,6 +19273,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -19067,6 +19332,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -19118,6 +19386,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -19223,6 +19492,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -19470,6 +19745,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -19637,6 +19922,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -19671,6 +19957,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -19705,6 +19992,7 @@ private constructor( discount = thresholdTotalAmount.discount externalPriceId = thresholdTotalAmount.externalPriceId fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = thresholdTotalAmount.invoicingCycleConfiguration item = thresholdTotalAmount.item maximum = thresholdTotalAmount.maximum @@ -20055,6 +20343,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -20323,6 +20625,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -20357,6 +20660,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -20397,6 +20701,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -20448,6 +20753,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -22256,6 +22562,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -22290,6 +22597,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -22312,7 +22620,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackage @@ -22332,6 +22640,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -22390,6 +22699,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -22441,6 +22753,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -22546,6 +22859,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -22793,6 +23112,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -22959,6 +23288,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -22993,6 +23323,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -23027,6 +23358,7 @@ private constructor( discount = tieredPackage.discount externalPriceId = tieredPackage.externalPriceId fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration item = tieredPackage.item maximum = tieredPackage.maximum @@ -23377,6 +23709,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -23645,6 +23991,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -23679,6 +24026,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -23719,6 +24067,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -23770,6 +24119,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -25569,6 +25919,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -25603,6 +25954,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -25625,7 +25977,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithMinimum @@ -25645,6 +25997,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -25703,6 +26056,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -25754,6 +26110,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -25859,6 +26216,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -26106,6 +26469,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -26272,6 +26645,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -26306,6 +26680,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -26340,6 +26715,7 @@ private constructor( discount = tieredWithMinimum.discount externalPriceId = tieredWithMinimum.externalPriceId fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration item = tieredWithMinimum.item maximum = tieredWithMinimum.maximum @@ -26690,6 +27066,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -26958,6 +27348,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -26992,6 +27383,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -27032,6 +27424,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -27083,6 +27476,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -28966,6 +29360,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -29000,6 +29395,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -29022,7 +29418,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTiered @@ -29043,6 +29439,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedTieredConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -29103,6 +29500,9 @@ private constructor( @JsonProperty("grouped_tiered_config") @ExcludeMissing groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -29152,6 +29552,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedTieredConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -29265,6 +29666,12 @@ private constructor( fun groupedTieredConfig(): GroupedTieredConfig = groupedTieredConfig.getRequired("grouped_tiered_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -29513,6 +29920,16 @@ private constructor( @ExcludeMissing fun _groupedTieredConfig(): JsonField = groupedTieredConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -29670,6 +30087,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedTieredConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -29704,6 +30122,7 @@ private constructor( private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null private var groupedTieredConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -29738,6 +30157,7 @@ private constructor( externalPriceId = groupedTiered.externalPriceId fixedPriceQuantity = groupedTiered.fixedPriceQuantity groupedTieredConfig = groupedTiered.groupedTieredConfig + invoiceGroupingKey = groupedTiered.invoiceGroupingKey invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration item = groupedTiered.item maximum = groupedTiered.maximum @@ -30102,6 +30522,20 @@ private constructor( this.groupedTieredConfig = groupedTieredConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -30356,6 +30790,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedTieredConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -30390,6 +30825,7 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -30430,6 +30866,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedTieredConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -30481,6 +30918,7 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (groupedTieredConfig.asKnown()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -32280,6 +32718,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredConfig == other.groupedTieredConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -32314,6 +32753,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedTieredConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -32335,7 +32775,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackageWithMinimum @@ -32355,6 +32795,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -32413,6 +32854,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -32465,6 +32909,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -32570,6 +33015,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -32817,6 +33268,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -32984,6 +33445,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -33018,6 +33480,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -33053,6 +33516,7 @@ private constructor( discount = tieredPackageWithMinimum.discount externalPriceId = tieredPackageWithMinimum.externalPriceId fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey invoicingCycleConfiguration = tieredPackageWithMinimum.invoicingCycleConfiguration item = tieredPackageWithMinimum.item maximum = tieredPackageWithMinimum.maximum @@ -33405,6 +33869,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -33674,6 +34152,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -33708,6 +34187,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -33748,6 +34228,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -33799,6 +34280,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -35639,6 +36121,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -35673,6 +36156,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -35695,7 +36179,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class PackageWithAllocation @@ -35715,6 +36199,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -35773,6 +36258,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -35824,6 +36312,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -35929,6 +36418,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -36176,6 +36671,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -36343,6 +36848,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -36377,6 +36883,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -36411,6 +36918,7 @@ private constructor( discount = packageWithAllocation.discount externalPriceId = packageWithAllocation.externalPriceId fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = packageWithAllocation.invoicingCycleConfiguration item = packageWithAllocation.item maximum = packageWithAllocation.maximum @@ -36761,6 +37269,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -37030,6 +37552,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -37064,6 +37587,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -37104,6 +37628,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -37155,6 +37680,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -38766,6 +39292,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -38800,6 +39327,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -38822,7 +39350,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithPercent @@ -38842,6 +39370,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -38900,6 +39429,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -38951,6 +39483,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -39056,6 +39589,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -39303,6 +39842,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -39469,6 +40018,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -39503,6 +40053,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -39537,6 +40088,7 @@ private constructor( discount = unitWithPercent.discount externalPriceId = unitWithPercent.externalPriceId fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration item = unitWithPercent.item maximum = unitWithPercent.maximum @@ -39887,6 +40439,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -40156,6 +40722,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -40190,6 +40757,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -40230,6 +40798,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -40281,6 +40850,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -41848,6 +42418,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -41882,6 +42453,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -41904,7 +42476,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithAllocation @@ -41924,6 +42496,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val matrixWithAllocationConfig: JsonField, @@ -41982,6 +42555,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -42033,6 +42609,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixWithAllocationConfig, @@ -42138,6 +42715,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -42385,6 +42968,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -42552,6 +43145,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixWithAllocationConfig() @@ -42586,6 +43180,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var matrixWithAllocationConfig: JsonField? = null @@ -42620,6 +43215,7 @@ private constructor( discount = matrixWithAllocation.discount externalPriceId = matrixWithAllocation.externalPriceId fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = matrixWithAllocation.invoicingCycleConfiguration item = matrixWithAllocation.item matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig @@ -42970,6 +43566,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -43238,6 +43848,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixWithAllocationConfig() @@ -43272,6 +43883,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), @@ -43312,6 +43924,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() matrixWithAllocationConfig().validate() @@ -43363,6 +43976,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (matrixWithAllocationConfig.asKnown()?.validity() ?: 0) + @@ -44716,6 +45330,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithAllocationConfig == other.matrixWithAllocationConfig && @@ -44750,6 +45365,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixWithAllocationConfig, @@ -44772,7 +45388,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -44792,6 +45408,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -44850,6 +45467,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -44901,6 +45521,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -45006,6 +45627,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -45253,6 +45880,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -45420,6 +46057,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -45454,6 +46092,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -45488,6 +46127,7 @@ private constructor( discount = tieredWithProration.discount externalPriceId = tieredWithProration.externalPriceId fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration item = tieredWithProration.item maximum = tieredWithProration.maximum @@ -45838,6 +46478,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -46106,6 +46760,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -46140,6 +46795,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -46180,6 +46836,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -46231,6 +46888,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -47988,6 +48646,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -48022,6 +48681,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -48044,7 +48704,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithProration @@ -48064,6 +48724,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -48122,6 +48783,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -48173,6 +48837,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -48278,6 +48943,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -48525,6 +49196,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -48691,6 +49372,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -48725,6 +49407,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -48759,6 +49442,7 @@ private constructor( discount = unitWithProration.discount externalPriceId = unitWithProration.externalPriceId fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration item = unitWithProration.item maximum = unitWithProration.maximum @@ -49109,6 +49793,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -49377,6 +50075,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -49411,6 +50110,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -49451,6 +50151,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -49502,6 +50203,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -51027,6 +51729,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -51061,6 +51764,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -51083,7 +51787,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedAllocation @@ -51104,6 +51808,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedAllocationConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -51164,6 +51869,9 @@ private constructor( @JsonProperty("grouped_allocation_config") @ExcludeMissing groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -51213,6 +51921,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedAllocationConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -51326,6 +52035,12 @@ private constructor( fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig.getRequired("grouped_allocation_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -51574,6 +52289,16 @@ private constructor( @ExcludeMissing fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -51731,6 +52456,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedAllocationConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -51765,6 +52491,7 @@ private constructor( private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null private var groupedAllocationConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -51799,6 +52526,7 @@ private constructor( externalPriceId = groupedAllocation.externalPriceId fixedPriceQuantity = groupedAllocation.fixedPriceQuantity groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration item = groupedAllocation.item maximum = groupedAllocation.maximum @@ -52163,6 +52891,20 @@ private constructor( groupedAllocationConfig: JsonField ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -52417,6 +53159,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedAllocationConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -52451,6 +53194,7 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -52491,6 +53235,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedAllocationConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -52542,6 +53287,7 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (groupedAllocationConfig.asKnown()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -54161,6 +54907,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedAllocationConfig == other.groupedAllocationConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -54195,6 +54942,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedAllocationConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -54216,7 +54964,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithProration @@ -54237,6 +54985,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -54297,6 +55046,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -54346,6 +55098,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -54459,6 +55212,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -54707,6 +55466,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -54864,6 +55633,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -54898,6 +55668,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -54932,6 +55703,7 @@ private constructor( discount = bulkWithProration.discount externalPriceId = bulkWithProration.externalPriceId fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration item = bulkWithProration.item maximum = bulkWithProration.maximum @@ -55296,6 +56068,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -55550,6 +56336,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -55584,6 +56371,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -55624,6 +56412,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -55675,6 +56464,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -57425,6 +58215,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -57459,6 +58250,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -57480,7 +58272,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithProratedMinimum @@ -57501,6 +58293,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedWithProratedMinimumConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -57562,6 +58355,9 @@ private constructor( @ExcludeMissing groupedWithProratedMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -57611,6 +58407,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedWithProratedMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -57724,6 +58521,12 @@ private constructor( fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -57973,6 +58776,16 @@ private constructor( fun _groupedWithProratedMinimumConfig(): JsonField = groupedWithProratedMinimumConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -58131,6 +58944,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedWithProratedMinimumConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -58167,6 +58981,7 @@ private constructor( private var groupedWithProratedMinimumConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -58202,6 +59017,7 @@ private constructor( fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity groupedWithProratedMinimumConfig = groupedWithProratedMinimum.groupedWithProratedMinimumConfig + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration item = groupedWithProratedMinimum.item maximum = groupedWithProratedMinimum.maximum @@ -58569,6 +59385,20 @@ private constructor( groupedWithProratedMinimumConfig: JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -58823,6 +59653,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedWithProratedMinimumConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -58860,6 +59691,7 @@ private constructor( "groupedWithProratedMinimumConfig", groupedWithProratedMinimumConfig, ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -58900,6 +59732,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedWithProratedMinimumConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -58951,6 +59784,7 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (groupedWithProratedMinimumConfig.asKnown()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -60564,6 +61398,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -60598,6 +61433,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedWithProratedMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -60619,7 +61455,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithMeteredMinimum @@ -60640,6 +61476,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -60701,6 +61538,9 @@ private constructor( @ExcludeMissing groupedWithMeteredMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -60750,6 +61590,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedWithMeteredMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -60863,6 +61704,12 @@ private constructor( fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -61112,6 +61959,16 @@ private constructor( fun _groupedWithMeteredMinimumConfig(): JsonField = groupedWithMeteredMinimumConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -61270,6 +62127,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedWithMeteredMinimumConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -61306,6 +62164,7 @@ private constructor( private var groupedWithMeteredMinimumConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -61341,6 +62200,7 @@ private constructor( fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity groupedWithMeteredMinimumConfig = groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration item = groupedWithMeteredMinimum.item maximum = groupedWithMeteredMinimum.maximum @@ -61707,6 +62567,20 @@ private constructor( groupedWithMeteredMinimumConfig: JsonField ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -61961,6 +62835,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedWithMeteredMinimumConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -61998,6 +62873,7 @@ private constructor( "groupedWithMeteredMinimumConfig", groupedWithMeteredMinimumConfig, ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -62038,6 +62914,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedWithMeteredMinimumConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -62089,6 +62966,7 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (groupedWithMeteredMinimumConfig.asKnown()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -64329,6 +65207,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -64363,6 +65242,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedWithMeteredMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -64384,7 +65264,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -64405,6 +65285,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedWithMinMaxThresholdsConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -64466,6 +65347,9 @@ private constructor( @ExcludeMissing groupedWithMinMaxThresholdsConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -64515,6 +65399,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedWithMinMaxThresholdsConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -64628,6 +65513,12 @@ private constructor( fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -64877,6 +65768,16 @@ private constructor( fun _groupedWithMinMaxThresholdsConfig(): JsonField = groupedWithMinMaxThresholdsConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -65035,6 +65936,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedWithMinMaxThresholdsConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -65071,6 +65973,7 @@ private constructor( private var groupedWithMinMaxThresholdsConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -65106,6 +66009,7 @@ private constructor( fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration item = groupedWithMinMaxThresholds.item @@ -65474,6 +66378,20 @@ private constructor( groupedWithMinMaxThresholdsConfig: JsonField ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -65728,6 +66646,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedWithMinMaxThresholdsConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -65765,6 +66684,7 @@ private constructor( "groupedWithMinMaxThresholdsConfig", groupedWithMinMaxThresholdsConfig, ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -65805,6 +66725,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedWithMinMaxThresholdsConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -65856,6 +66777,7 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (groupedWithMinMaxThresholdsConfig.asKnown()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -67531,6 +68453,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -67565,6 +68488,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedWithMinMaxThresholdsConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -67586,7 +68510,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithDisplayName @@ -67606,6 +68530,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val matrixWithDisplayNameConfig: JsonField, @@ -67664,6 +68589,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -67715,6 +68643,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixWithDisplayNameConfig, @@ -67820,6 +68749,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -68067,6 +69002,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -68234,6 +69179,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixWithDisplayNameConfig() @@ -68268,6 +69214,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var matrixWithDisplayNameConfig: JsonField? = null @@ -68302,6 +69249,7 @@ private constructor( discount = matrixWithDisplayName.discount externalPriceId = matrixWithDisplayName.externalPriceId fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration item = matrixWithDisplayName.item matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig @@ -68652,6 +69600,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -68921,6 +69883,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixWithDisplayNameConfig() @@ -68955,6 +69918,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), @@ -68995,6 +69959,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() matrixWithDisplayNameConfig().validate() @@ -69046,6 +70011,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (matrixWithDisplayNameConfig.asKnown()?.validity() ?: 0) + @@ -70896,6 +71862,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && @@ -70930,6 +71897,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixWithDisplayNameConfig, @@ -70952,7 +71920,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTieredPackage @@ -70973,6 +71941,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedTieredPackageConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -71033,6 +72002,9 @@ private constructor( @JsonProperty("grouped_tiered_package_config") @ExcludeMissing groupedTieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -71082,6 +72054,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedTieredPackageConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -71195,6 +72168,12 @@ private constructor( fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -71444,6 +72423,16 @@ private constructor( fun _groupedTieredPackageConfig(): JsonField = groupedTieredPackageConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -71601,6 +72590,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedTieredPackageConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -71635,6 +72625,7 @@ private constructor( private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null private var groupedTieredPackageConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -71669,6 +72660,7 @@ private constructor( externalPriceId = groupedTieredPackage.externalPriceId fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration item = groupedTieredPackage.item maximum = groupedTieredPackage.maximum @@ -72033,6 +73025,20 @@ private constructor( groupedTieredPackageConfig: JsonField ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -72287,6 +73293,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedTieredPackageConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -72321,6 +73328,7 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -72361,6 +73369,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedTieredPackageConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -72412,6 +73421,7 @@ private constructor( (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + (groupedTieredPackageConfig.asKnown()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -74254,6 +75264,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredPackageConfig == other.groupedTieredPackageConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -74288,6 +75299,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedTieredPackageConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -74309,7 +75321,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MaxGroupTieredPackage @@ -74329,6 +75341,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maxGroupTieredPackageConfig: JsonField, @@ -74387,6 +75400,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -74438,6 +75454,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maxGroupTieredPackageConfig, @@ -74543,6 +75560,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -74790,6 +75813,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -74957,6 +75990,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maxGroupTieredPackageConfig() @@ -74991,6 +76025,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maxGroupTieredPackageConfig: JsonField? = null @@ -75025,6 +76060,7 @@ private constructor( discount = maxGroupTieredPackage.discount externalPriceId = maxGroupTieredPackage.externalPriceId fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration item = maxGroupTieredPackage.item maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig @@ -75375,6 +76411,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -75644,6 +76694,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maxGroupTieredPackageConfig() @@ -75678,6 +76729,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), @@ -75718,6 +76770,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maxGroupTieredPackageConfig().validate() @@ -75769,6 +76822,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maxGroupTieredPackageConfig.asKnown()?.validity() ?: 0) + @@ -77614,6 +78668,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && @@ -77648,6 +78703,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maxGroupTieredPackageConfig, @@ -77670,7 +78726,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ScalableMatrixWithUnitPricing @@ -77690,6 +78746,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -77749,6 +78806,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -77801,6 +78861,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -77906,6 +78967,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -78155,6 +79222,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -78323,6 +79400,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -78357,6 +79435,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -78397,6 +79476,7 @@ private constructor( discount = scalableMatrixWithUnitPricing.discount externalPriceId = scalableMatrixWithUnitPricing.externalPriceId fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey invoicingCycleConfiguration = scalableMatrixWithUnitPricing.invoicingCycleConfiguration item = scalableMatrixWithUnitPricing.item @@ -78751,6 +79831,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -79025,6 +80119,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -79059,6 +80154,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -79102,6 +80198,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -79153,6 +80250,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -81205,6 +82303,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -81239,6 +82338,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -81261,7 +82361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ScalableMatrixWithTieredPricing @@ -81281,6 +82381,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -81340,6 +82441,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -81393,6 +82497,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -81498,6 +82603,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -81747,6 +82858,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -81915,6 +83036,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -81949,6 +83071,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -81989,6 +83112,7 @@ private constructor( discount = scalableMatrixWithTieredPricing.discount externalPriceId = scalableMatrixWithTieredPricing.externalPriceId fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = scalableMatrixWithTieredPricing.invoicingCycleConfiguration item = scalableMatrixWithTieredPricing.item @@ -82343,6 +83467,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -82618,6 +83756,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -82652,6 +83791,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -82695,6 +83835,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -82746,6 +83887,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -84922,6 +86064,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -84957,6 +86100,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -84979,7 +86123,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class CumulativeGroupedBulk @@ -85000,6 +86144,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -85060,6 +86205,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -85109,6 +86257,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -85222,6 +86371,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -85471,6 +86626,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -85628,6 +86793,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -85662,6 +86828,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -85696,6 +86863,7 @@ private constructor( discount = cumulativeGroupedBulk.discount externalPriceId = cumulativeGroupedBulk.externalPriceId fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration item = cumulativeGroupedBulk.item maximum = cumulativeGroupedBulk.maximum @@ -86061,6 +87229,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -86315,6 +87497,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -86349,6 +87532,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -86389,6 +87573,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -86440,6 +87625,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -88283,6 +89469,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -88317,6 +89504,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -88338,7 +89526,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -88359,6 +89547,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -88420,6 +89609,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -88469,6 +89661,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -88582,6 +89775,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -88831,6 +90030,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -88989,6 +90198,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -89025,6 +90235,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -89060,6 +90271,7 @@ private constructor( discount = cumulativeGroupedAllocation.discount externalPriceId = cumulativeGroupedAllocation.externalPriceId fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration item = cumulativeGroupedAllocation.item @@ -89428,6 +90640,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -89682,6 +90908,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -89719,6 +90946,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -89759,6 +90987,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -89810,6 +91039,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -91486,6 +92716,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -91520,6 +92751,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -91541,7 +92773,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MinimumComposite @@ -91561,6 +92793,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -91619,6 +92852,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -91670,6 +92906,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -91775,6 +93012,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -92022,6 +93265,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -92188,6 +93441,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -92222,6 +93476,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -92256,6 +93511,7 @@ private constructor( discount = minimumComposite.discount externalPriceId = minimumComposite.externalPriceId fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration item = minimumComposite.item maximum = minimumComposite.maximum @@ -92606,6 +93862,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -92875,6 +94145,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -92909,6 +94180,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -92949,6 +94221,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -93000,6 +94273,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -94567,6 +95841,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -94601,6 +95876,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -94623,7 +95899,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Percent @@ -94643,6 +95919,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -94701,6 +95978,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -94752,6 +96032,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -94857,6 +96138,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -95103,6 +96390,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -95269,6 +96566,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -95303,6 +96601,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -95336,6 +96635,7 @@ private constructor( discount = percent.discount externalPriceId = percent.externalPriceId fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration item = percent.item maximum = percent.maximum @@ -95686,6 +96986,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -95954,6 +97268,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -95988,6 +97303,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -96028,6 +97344,7 @@ private constructor( discount()?.validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -96079,6 +97396,7 @@ private constructor( (discount.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -97597,6 +98915,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -97631,6 +98950,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -97653,7 +98973,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class EventOutput @@ -97674,6 +98994,7 @@ private constructor( private val eventOutputConfig: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -97734,6 +99055,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -97783,6 +99107,7 @@ private constructor( eventOutputConfig, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -97896,6 +99221,12 @@ private constructor( */ fun fixedPriceQuantity(): Double? = fixedPriceQuantity.getNullable("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): String? = invoiceGroupingKey.getNullable("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -98144,6 +99475,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -98301,6 +99642,7 @@ private constructor( * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -98335,6 +99677,7 @@ private constructor( private var eventOutputConfig: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -98368,6 +99711,7 @@ private constructor( eventOutputConfig = eventOutput.eventOutputConfig externalPriceId = eventOutput.externalPriceId fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration item = eventOutput.item maximum = eventOutput.maximum @@ -98732,6 +100076,20 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -98986,6 +100344,7 @@ private constructor( * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -99020,6 +100379,7 @@ private constructor( checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -99060,6 +100420,7 @@ private constructor( eventOutputConfig().validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration()?.validate() item().validate() maximum()?.validate() @@ -99111,6 +100472,7 @@ private constructor( (eventOutputConfig.asKnown()?.validity() ?: 0) + (if (externalPriceId.asKnown() == null) 0 else 1) + (if (fixedPriceQuantity.asKnown() == null) 0 else 1) + + (if (invoiceGroupingKey.asKnown() == null) 0 else 1) + (invoicingCycleConfiguration.asKnown()?.validity() ?: 0) + (item.asKnown()?.validity() ?: 0) + (maximum.asKnown()?.validity() ?: 0) + @@ -100734,6 +102096,7 @@ private constructor( eventOutputConfig == other.eventOutputConfig && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -100768,6 +102131,7 @@ private constructor( eventOutputConfig, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -100789,6 +102153,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } } diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt index c2171dba4..7e85c1976 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt @@ -85,13 +85,16 @@ interface CreditBlockServiceAsync { /** * This endpoint returns the credit block and its associated purchasing invoices. * - * If a credit block was purchased (as opposed to being manually added or allocated from a - * subscription), this endpoint returns the invoices that were created to charge the customer - * for the credit block. For credit blocks with payment schedules spanning multiple periods - * (e.g., monthly payments over 12 months), multiple invoices will be returned. + * If a credit block was purchased (as opposed to being manually added), this endpoint returns + * the invoices that were created to charge the customer for the credit block. For credit blocks + * with payment schedules spanning multiple periods (e.g., monthly payments over 12 months), + * multiple invoices will be returned. * - * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices - * list is returned. + * For credit blocks created by subscription allocation prices, this endpoint returns the + * subscription invoice containing the allocation line item that created the block. + * + * If the credit block was not purchased (e.g., manual increment), an empty invoices list is + * returned. * * **Note: This endpoint is currently experimental and its interface may change in future * releases. Please contact support before building production integrations against this diff --git a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt index cce94c002..e363ccd80 100644 --- a/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt +++ b/orb-kotlin-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt @@ -82,13 +82,16 @@ interface CreditBlockService { /** * This endpoint returns the credit block and its associated purchasing invoices. * - * If a credit block was purchased (as opposed to being manually added or allocated from a - * subscription), this endpoint returns the invoices that were created to charge the customer - * for the credit block. For credit blocks with payment schedules spanning multiple periods - * (e.g., monthly payments over 12 months), multiple invoices will be returned. + * If a credit block was purchased (as opposed to being manually added), this endpoint returns + * the invoices that were created to charge the customer for the credit block. For credit blocks + * with payment schedules spanning multiple periods (e.g., monthly payments over 12 months), + * multiple invoices will be returned. * - * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices - * list is returned. + * For credit blocks created by subscription allocation prices, this endpoint returns the + * subscription invoice containing the allocation line item that created the block. + * + * If the credit block was not purchased (e.g., manual increment), an empty invoices list is + * returned. * * **Note: This endpoint is currently experimental and its interface may change in future * releases. Please contact support before building production integrations against this diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 5cde73367..a3dec90ea 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -86,6 +86,7 @@ internal class AggregatedCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -231,6 +232,7 @@ internal class AggregatedCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -386,6 +388,7 @@ internal class AggregatedCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index 5890c5be0..3f835db3b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -332,6 +332,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -816,6 +817,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1298,6 +1300,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1763,6 +1766,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2257,6 +2261,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2741,6 +2746,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 2cf8cd2c2..1ed44b789 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -105,6 +105,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -272,6 +273,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -448,6 +450,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index ff5de40ee..4dfcd2a3b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -105,6 +105,7 @@ internal class CustomerCostListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -272,6 +273,7 @@ internal class CustomerCostListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -448,6 +450,7 @@ internal class CustomerCostListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 80254f600..c70f5ded4 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -273,6 +273,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -728,6 +729,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 830687f94..c58ace366 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -273,6 +273,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -727,6 +728,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index e8d42a435..7a16647f3 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -294,6 +294,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -774,6 +775,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1257,6 +1259,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index 324a46f65..85f91ac8a 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -273,6 +273,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -727,6 +728,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index 05634410d..0918738c1 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -294,6 +294,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -774,6 +775,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1257,6 +1259,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 4d9316dcf..0ace4ef90 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -273,6 +273,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -727,6 +728,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index 2b20fe226..ce720c2ab 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -269,6 +269,7 @@ internal class IncrementLedgerEntryTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -693,6 +694,7 @@ internal class IncrementLedgerEntryTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1124,6 +1126,7 @@ internal class IncrementLedgerEntryTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 5b8dfe0d7..d295acac2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -210,6 +210,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -586,6 +587,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -968,6 +970,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index 54595f0d5..77cdf7fc2 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -108,6 +108,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -295,6 +296,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -487,6 +489,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index 69cd680d7..1fda367ed 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -234,6 +234,7 @@ internal class InvoiceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -620,6 +621,7 @@ internal class InvoiceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1018,6 +1020,7 @@ internal class InvoiceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 4a387af52..489827f2f 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -206,6 +206,7 @@ internal class InvoiceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -573,6 +574,7 @@ internal class InvoiceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -944,6 +946,7 @@ internal class InvoiceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 909552142..bd76dd312 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -446,6 +446,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -617,6 +618,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1054,6 +1056,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1583,6 +1586,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2210,6 +2214,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2374,6 +2379,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2794,6 +2800,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3291,6 +3298,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3912,6 +3920,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4083,6 +4092,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4520,6 +4530,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5049,6 +5060,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 16697ddb8..463821d5b 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -78,6 +78,7 @@ internal class PerPriceCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -211,6 +212,7 @@ internal class PerPriceCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -348,6 +350,7 @@ internal class PerPriceCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index 749c61a5f..ca5207689 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -234,6 +234,7 @@ internal class PlanListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -532,6 +533,7 @@ internal class PlanListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -842,6 +844,7 @@ internal class PlanListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 395168c41..4df55b073 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -219,6 +219,7 @@ internal class PlanTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -515,6 +516,7 @@ internal class PlanTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -806,6 +808,7 @@ internal class PlanTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index 0b1bb8780..a5af1a8d6 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -110,6 +110,7 @@ internal class PlanVersionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -277,6 +278,7 @@ internal class PlanVersionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -443,6 +445,7 @@ internal class PlanVersionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index a417a9503..8c899d564 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -92,6 +92,7 @@ internal class PriceIntervalTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -246,6 +247,7 @@ internal class PriceIntervalTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -402,6 +404,7 @@ internal class PriceIntervalTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index 65d4d7789..88bc2fd79 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -78,6 +78,7 @@ internal class PriceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -210,6 +211,7 @@ internal class PriceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -345,6 +347,7 @@ internal class PriceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 6f80c7fbc..84b19e085 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -80,6 +80,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -242,6 +243,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -376,6 +378,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -549,6 +552,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -699,6 +703,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -870,6 +875,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1023,6 +1029,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1206,6 +1213,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1337,6 +1345,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1501,6 +1510,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1638,6 +1648,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1811,6 +1822,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1954,6 +1966,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2136,6 +2149,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2288,6 +2302,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2466,6 +2481,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2614,6 +2630,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2797,6 +2814,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2965,6 +2983,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3143,6 +3162,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3276,6 +3296,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3463,6 +3484,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3617,6 +3639,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3787,6 +3810,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3925,6 +3949,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4092,6 +4117,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4229,6 +4255,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4405,6 +4432,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4549,6 +4577,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4722,6 +4751,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4863,6 +4893,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5031,6 +5062,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5174,6 +5206,7 @@ internal class PriceTest { .overageUnitRate("overage_unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5344,6 +5377,7 @@ internal class PriceTest { .overageUnitRate("overage_unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5491,6 +5525,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5670,6 +5705,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5810,6 +5846,7 @@ internal class PriceTest { .unitRate("unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5983,6 +6020,7 @@ internal class PriceTest { .unitRate("unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6140,6 +6178,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6330,6 +6369,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6473,6 +6513,7 @@ internal class PriceTest { .perUnitRate("per_unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6649,6 +6690,7 @@ internal class PriceTest { .perUnitRate("per_unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6782,6 +6824,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6958,6 +7001,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7120,6 +7164,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7301,6 +7346,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7434,6 +7480,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7615,6 +7662,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7771,6 +7819,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7957,6 +8006,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8114,6 +8164,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8317,6 +8368,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8498,6 +8550,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8675,6 +8728,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8818,6 +8872,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8994,6 +9049,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9125,6 +9181,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9292,6 +9349,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9429,6 +9487,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9591,6 +9650,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9730,6 +9790,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9898,6 +9959,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 5c465227f..95c0fac19 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -493,6 +493,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -690,6 +691,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1196,6 +1198,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1818,6 +1821,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2507,6 +2511,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2687,6 +2692,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3153,6 +3159,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3730,6 +3737,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4441,6 +4449,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4638,6 +4647,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5144,6 +5154,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5766,6 +5777,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index 9914686c5..8c2ca741c 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -493,6 +493,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -690,6 +691,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1196,6 +1198,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1818,6 +1821,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2507,6 +2511,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2687,6 +2692,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3153,6 +3159,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3730,6 +3737,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4441,6 +4449,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4638,6 +4647,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5144,6 +5154,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5766,6 +5777,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 53f449ab6..f7afdeeec 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -493,6 +493,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -690,6 +691,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1196,6 +1198,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1818,6 +1821,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2507,6 +2511,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2687,6 +2692,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3153,6 +3159,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3730,6 +3737,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4441,6 +4449,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4638,6 +4647,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5144,6 +5154,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5766,6 +5777,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index b10c24d7e..4c93b6908 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -105,6 +105,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -272,6 +273,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -448,6 +450,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index 7ca1a3807..7849dcf5d 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -446,6 +446,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -617,6 +618,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1138,6 +1140,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1302,6 +1305,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1831,6 +1835,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2002,6 +2007,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 00056652a..4af35dcbc 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -489,6 +489,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -686,6 +687,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1240,6 +1242,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1420,6 +1423,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1995,6 +1999,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2192,6 +2197,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) From f108cca9594df29f98fee72963ce55534cee1b50 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 18:15:07 +0000 Subject: [PATCH 51/52] feat(api): api update --- .stats.yml | 4 ++-- .../withorb/api/models/LicenseTypeCreateParamsTest.kt | 9 ++++----- .../api/services/async/LicenseTypeServiceAsyncTest.kt | 2 +- .../api/services/blocking/LicenseTypeServiceTest.kt | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.stats.yml b/.stats.yml index 87a29a7d9..9eac7077a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-2b77f13a159cf689a3bba6ac5ff03b6c0df62b772e2da04aff52be86710ca4d4.yml -openapi_spec_hash: 28a3f685403d98ddd68b427d92ed28fb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-91a51960dab258d5435cc2a7f47760fd81e4b711b891a1fde3d98757e85e8add.yml +openapi_spec_hash: 192e4e94264db429260169f0b2e731ce config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt index 4a11b64bd..d03341e56 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt @@ -9,17 +9,16 @@ internal class LicenseTypeCreateParamsTest { @Test fun create() { - LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() } @Test fun body() { - val params = - LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + val params = LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() val body = params._body() - assertThat(body.groupingKey()).isEqualTo("grouping_key") - assertThat(body.name()).isEqualTo("name") + assertThat(body.groupingKey()).isEqualTo("x") + assertThat(body.name()).isEqualTo("x") } } diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt index 6817aad90..18568391e 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt @@ -22,7 +22,7 @@ internal class LicenseTypeServiceAsyncTest { val licenseType = licenseTypeServiceAsync.create( - LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() ) licenseType.validate() diff --git a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt index e86dcf903..11454dfc8 100644 --- a/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt +++ b/orb-kotlin-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt @@ -22,7 +22,7 @@ internal class LicenseTypeServiceTest { val licenseType = licenseTypeService.create( - LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() ) licenseType.validate() From bf92205ea004b97865504127d4fdc4179a46e046 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 18:16:08 +0000 Subject: [PATCH 52/52] release: 1.13.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 67 +++++++++++++++++++++++++++++++++++ README.md | 6 ++-- build.gradle.kts | 2 +- 4 files changed, 72 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index de0960aba..f94eeca26 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.12.0" + ".": "1.13.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d0690ca0..75f4ea29f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,72 @@ # Changelog +## 1.13.0 (2026-04-13) + +Full Changelog: [v1.12.0...v1.13.0](https://github.com/orbcorp/orb-kotlin/compare/v1.12.0...v1.13.0) + +### Features + +* **api:** api update ([f108cca](https://github.com/orbcorp/orb-kotlin/commit/f108cca9594df29f98fee72963ce55534cee1b50)) +* **api:** api update ([ffa5b92](https://github.com/orbcorp/orb-kotlin/commit/ffa5b92f2d89afa95c12a8d4fd6c608c983b3eac)) +* **api:** api update ([2f25f86](https://github.com/orbcorp/orb-kotlin/commit/2f25f860175c24c187e7f8ffd2d283f0017b8722)) +* **api:** api update ([a0f53b0](https://github.com/orbcorp/orb-kotlin/commit/a0f53b00b27077118e8da9afc249843109aad174)) +* **api:** api update ([86ce6f3](https://github.com/orbcorp/orb-kotlin/commit/86ce6f3f76500235d4ebba8c96e2a4c84d4343db)) +* **api:** api update ([7091a72](https://github.com/orbcorp/orb-kotlin/commit/7091a7208d02be59e8e72fcec879ca805cf00813)) +* **api:** api update ([0e05662](https://github.com/orbcorp/orb-kotlin/commit/0e05662b947ceb6d28995075cc59fad024d6161f)) +* **api:** api update ([e397453](https://github.com/orbcorp/orb-kotlin/commit/e3974536b461231fef00e23c9e02fe6b274b6bd1)) +* **api:** api update ([723f156](https://github.com/orbcorp/orb-kotlin/commit/723f156299560f9a997cdb75603fc96dcbbe6906)) +* **api:** api update ([fe15a1e](https://github.com/orbcorp/orb-kotlin/commit/fe15a1ef1f9ecba723e359bcba1f36a629d3d960)) +* **api:** api update ([a018be0](https://github.com/orbcorp/orb-kotlin/commit/a018be0afe3879a198d667714f0de75f2c5cdbf9)) +* **api:** api update ([63f49a7](https://github.com/orbcorp/orb-kotlin/commit/63f49a7d9be8e33bbdc0489310fe5ef7f5f1df44)) +* **api:** api update ([6de031f](https://github.com/orbcorp/orb-kotlin/commit/6de031f604efd812fc895269568e4debf2b36566)) +* **api:** api update ([9c54a99](https://github.com/orbcorp/orb-kotlin/commit/9c54a99fc2abd5d78d679967ddf8c48c960eeb03)) +* **api:** api update ([808e072](https://github.com/orbcorp/orb-kotlin/commit/808e0728d3848bdcbd4e3ace9e4cf7e3e7fe9852)) +* **api:** api update ([a4e55fc](https://github.com/orbcorp/orb-kotlin/commit/a4e55fcd736a0e61da05512f1015c542b77b2e01)) +* **api:** api update ([7df6475](https://github.com/orbcorp/orb-kotlin/commit/7df6475b8742a8d3755c77f2168bfafdc0bf660a)) +* **api:** manual updates ([d93464c](https://github.com/orbcorp/orb-kotlin/commit/d93464c286e31f707862d8a961c5f454351022e5)) +* **client:** add connection pooling option ([ce4d8a2](https://github.com/orbcorp/orb-kotlin/commit/ce4d8a2e387790b9a1faf40b8f04374a74c9110e)) +* **client:** add more convenience service method overloads ([c449333](https://github.com/orbcorp/orb-kotlin/commit/c449333d09d0b112178f42325b09fd7ff48811df)) + + +### Bug Fixes + +* **client:** allow updating header/query affecting fields in `toBuilder()` ([562fcc3](https://github.com/orbcorp/orb-kotlin/commit/562fcc3e28663dc802d801a6c359cbc5c04c681a)) +* **client:** incorrect `Retry-After` parsing ([3c13033](https://github.com/orbcorp/orb-kotlin/commit/3c13033d0e362da84b28e1b5e26ba32d69188bac)) +* fix request delays for retrying to be more respectful of high requested delays ([860ce4a](https://github.com/orbcorp/orb-kotlin/commit/860ce4a58b2d43cad76f218d23db8baccab57534)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([847e839](https://github.com/orbcorp/orb-kotlin/commit/847e8399ce5cd8c10fcf1abeeaba3184a0695b9f)) +* **docs:** add missing descriptions ([c57175f](https://github.com/orbcorp/orb-kotlin/commit/c57175fc1dc641c6d28ad1dc72cec513bc5982c2)) +* drop apache dependency ([2fb8c9e](https://github.com/orbcorp/orb-kotlin/commit/2fb8c9eb2ca0dbbf34cf0ec88e2053dae3af1df6)) +* **internal:** allow passing args to `./scripts/test` ([8b61c22](https://github.com/orbcorp/orb-kotlin/commit/8b61c22ee33f728ae31d37c535280c2ca0c6a364)) +* **internal:** bump ktfmt ([24a716a](https://github.com/orbcorp/orb-kotlin/commit/24a716abbe941baed09fedde8e5ef860e65e01ba)) +* **internal:** bump palantir-java-format ([8195969](https://github.com/orbcorp/orb-kotlin/commit/8195969d6833b6dbf576fe9a74e511ce8d1b4a00)) +* **internal:** codegen related update ([4e9e830](https://github.com/orbcorp/orb-kotlin/commit/4e9e830d982ed89d6e3f3a08e8dd952dedf44676)) +* **internal:** expand imports ([4e1cecf](https://github.com/orbcorp/orb-kotlin/commit/4e1cecf9966e60a856333a3fd94f08ffb5abe1d2)) +* **internal:** make `OkHttp` constructor internal ([2435e96](https://github.com/orbcorp/orb-kotlin/commit/2435e963adf84c275057b6a2e9ede78989e59cd0)) +* **internal:** tweak CI branches ([5fceea6](https://github.com/orbcorp/orb-kotlin/commit/5fceea66f7cc3148c01a0a33c81000cf1fbfd1a1)) +* **internal:** update `TestServerExtension` comment ([7eb1e48](https://github.com/orbcorp/orb-kotlin/commit/7eb1e48401da793d82b5b8465fef638088411e55)) +* **internal:** update gitignore ([fa67c12](https://github.com/orbcorp/orb-kotlin/commit/fa67c1226f96926bce3720704e5fff5a29871679)) +* **internal:** update multipart form array serialization ([f8ee810](https://github.com/orbcorp/orb-kotlin/commit/f8ee81005fb308a952e6fd946680c8e7d3f04190)) +* **internal:** update retry delay tests ([b77931f](https://github.com/orbcorp/orb-kotlin/commit/b77931f2d6025e820c84c9a01626321c73a65240)) +* **internal:** upgrade AssertJ ([8ea3731](https://github.com/orbcorp/orb-kotlin/commit/8ea373173f2b39a788ecd61aa1f4e83b9a27b8e4)) +* make `Properties` more resilient to `null` ([7104ce5](https://github.com/orbcorp/orb-kotlin/commit/7104ce5655136a86694abe6438bb8d7df7093ff9)) +* **test:** do not count install time for mock server timeout ([e2497db](https://github.com/orbcorp/orb-kotlin/commit/e2497db0a8bb5068d55a5ed257ebbad1e766bf2c)) +* **tests:** bump steady to v0.19.4 ([849d3de](https://github.com/orbcorp/orb-kotlin/commit/849d3de8b4ea87f9d0468a7375f0fdcb643e5cbc)) +* **tests:** bump steady to v0.19.5 ([a10b512](https://github.com/orbcorp/orb-kotlin/commit/a10b51221a51c8316be0ea100d22aa621e1672ad)) +* **tests:** bump steady to v0.19.6 ([db03fe4](https://github.com/orbcorp/orb-kotlin/commit/db03fe4c53ad646d5de1f7bd7a58bb1d9554c768)) +* **tests:** bump steady to v0.19.7 ([7f90cdf](https://github.com/orbcorp/orb-kotlin/commit/7f90cdf8a4b13e32a35eb69e48643dc3bbf7388e)) +* **tests:** bump steady to v0.20.1 ([60af3d0](https://github.com/orbcorp/orb-kotlin/commit/60af3d0eafd87bccc861e9c586f384869042f50d)) +* **tests:** bump steady to v0.20.2 ([196c645](https://github.com/orbcorp/orb-kotlin/commit/196c645c4bf289fb6ecfa7165e8b417679c52f0e)) +* **tests:** update mock server to steady ([67887bf](https://github.com/orbcorp/orb-kotlin/commit/67887bfd41f3744589a59299b8b4b69c136dfc1e)) + + +### Documentation + +* improve examples ([f1ab4b8](https://github.com/orbcorp/orb-kotlin/commit/f1ab4b89f00819f7dc49af9c2163d5372a416327)) + ## 1.12.0 (2026-01-28) Full Changelog: [v1.11.0...v1.12.0](https://github.com/orbcorp/orb-kotlin/compare/v1.11.0...v1.12.0) diff --git a/README.md b/README.md index a7899e974..fde07cfeb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-kotlin)](https://central.sonatype.com/artifact/com.withorb.api/orb-kotlin/1.12.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-kotlin)](https://central.sonatype.com/artifact/com.withorb.api/orb-kotlin/1.13.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-kotlin:1.12.0") +implementation("com.withorb.api:orb-kotlin:1.13.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-kotlin:1.12.0") com.withorb.api orb-kotlin - 1.12.0 + 1.13.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 4fd74a10b..c78651cf6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.withorb.api" - version = "1.12.0" // x-release-please-version + version = "1.13.0" // x-release-please-version } subprojects {